about summary refs log tree commit diff
path: root/debug/tst-chk1.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-24 17:01:40 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-24 17:01:40 +0000
commita346370d582ed9be5e434f955c049e75abc37c28 (patch)
treed3bf31f79d210adfa9b58a906afe65237b879ae1 /debug/tst-chk1.c
parent34a15e61e019c0aaa6b56c79b75ddb0ded49f590 (diff)
downloadglibc-a346370d582ed9be5e434f955c049e75abc37c28.tar.gz
glibc-a346370d582ed9be5e434f955c049e75abc37c28.tar.xz
glibc-a346370d582ed9be5e434f955c049e75abc37c28.zip
* posix/bits/unistd.h (__readlinkat_chk): New prototype.
	(__readlinkat_alias): New alias.
	(readlinkat): New inline function.
	* include/unistd.h (readlinkat): Add libc_hidden_proto.
	* sysdeps/unix/sysv/linux/readlinkat.c (readlinkat): Add
	libc_hidden_def.
	* io/readlinkat.c (readlinkat): Likewise.
	* debug/readlinkat_chk.c: New file.
	* debug/Makefile (routines): Add readlinkat_chk.
	* debug/Versions (libc): Export __readlinkat_chk@@GLIBC_2.5.
	* debug/tst-chk1.c (do_test): Add readlinkat tests.

	* nis/nss_nisplus/nisplus-netgrp.c: Cleanups.
	code is possible.  Move compatibility code in .text.compat section.
	over gaih array.  There is only one function to call in the moment.
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r--debug/tst-chk1.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index ee080cef49..993dab63b2 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
 
@@ -944,6 +944,34 @@ do_test (void)
   CHK_FAIL_END
 #endif
 
+  int tmpfd = open ("/tmp", O_RDONLY | O_DIRECTORY);
+  if (tmpfd < 0)
+    FAIL ();
+
+  if (readlinkat (tmpfd, fname + sizeof ("/tmp/") - 1, readlinkbuf, 4) != 3
+      || memcmp (readlinkbuf, "bar", 3) != 0)
+    FAIL ();
+  if (readlinkat (tmpfd, fname + sizeof ("/tmp/") - 1, readlinkbuf + 1,
+		  l0 + 3) != 3
+      || memcmp (readlinkbuf, "bbar", 4) != 0)
+    FAIL ();
+
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  if (readlinkat (tmpfd, fname + sizeof ("/tmp/") - 1, readlinkbuf + 2,
+		  l0 + 3) != 3)
+    FAIL ();
+  CHK_FAIL_END
+
+  CHK_FAIL_START
+  if (readlinkat (tmpfd, fname + sizeof ("/tmp/") - 1, readlinkbuf + 3,
+		  4) != 3)
+    FAIL ();
+  CHK_FAIL_END
+#endif
+
+  close (tmpfd);
+
   char *cwd1 = getcwd (NULL, 0);
   if (cwd1 == NULL)
     FAIL ();