about summary refs log tree commit diff
path: root/debug/tst-chk1.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-07-18 21:07:28 +0000
committerUlrich Drepper <drepper@redhat.com>2005-07-18 21:07:28 +0000
commit9f3731cf7f8f1d1b4718fdbeae2ca5d46bbc6950 (patch)
tree1cbff2cd7ef38c777aa3a6c713b1513e038f2483 /debug/tst-chk1.c
parent0396de518e3ed6b4bebea10026ca5c7aaafa783f (diff)
downloadglibc-9f3731cf7f8f1d1b4718fdbeae2ca5d46bbc6950.tar.gz
glibc-9f3731cf7f8f1d1b4718fdbeae2ca5d46bbc6950.tar.xz
glibc-9f3731cf7f8f1d1b4718fdbeae2ca5d46bbc6950.zip
* nscd/grpcache.c (cache_addgr): Use correct maximum for group ID
	length.  Patch by Ivan Gyurdiev <ivg2@cornell.edu>.

	* debug/confstr_chk.c: New file.
	* debug/getdomainname_chk.c: New file.
	* debug/getgroups_chk.c: New file.
	* debug/gethostname_chk.c: New file.
	* debug/getlogin_r_chk.c: New file.
	* debug/ttyname_r_chk.c: New file.
	* posix/bits/unistd.h: Add definitions for new debug versions.
	* debug/tst-chk1.c: Add tests for new functions.
	* debug/Versions: Export new functions.
	* debug/Makefile (routines): Add new files.

	* stdlib/bits/stdlib.h: Fix typo.

	* manual/Makefile (libc/index.html): Depend on dir-add.texi.
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r--debug/tst-chk1.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index a83bd843c6..47938bbf36 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1083,7 +1083,75 @@ do_test (void)
 	}
       CHK_FAIL_END
 #endif
+      close (fd);
+    }
+
+  confstr (_CS_GNU_LIBC_VERSION, largebuf, sizeof (largebuf));
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  char smallbuf[1];
+  confstr (_CS_GNU_LIBC_VERSION, smallbuf, sizeof (largebuf));
+  CHK_FAIL_END
+#endif
+
+  gid_t grpslarge[5];
+  int ngr = getgroups (5, grpslarge);
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  char smallbuf[1];
+  ngr = getgroups (5, (gid_t *) smallbuf);
+  CHK_FAIL_END
+#endif
+
+  fd = open (_PATH_TTY, O_RDONLY);
+  if (fd != -1)
+    {
+      char enough[1000];
+      if (ttyname_r (fd, enough, sizeof (enough)) != 0)
+	{
+	  puts ("first ttyname_r failed");
+	  ret = 1;
+	}
+
+#if __USE_FORTIFY_LEVEL >= 1
+      CHK_FAIL_START
+      char smallbuf[2];
+      if (ttyname_r (fd, smallbuf, sizeof (smallbuf) + 1) == 0)
+	{
+	  puts ("second ttyname_r somehow suceeded");
+	  ret = 1;
+	}
+      CHK_FAIL_END
+#endif
+      close (fd);
     }
 
+  char hostnamelarge[1000];
+  gethostname (hostnamelarge, sizeof (hostnamelarge));
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  char smallbuf[1];
+  gethostname (smallbuf, sizeof (hostnamelarge));
+  CHK_FAIL_END
+#endif
+
+  char loginlarge[1000];
+  getlogin_r (loginlarge, sizeof (hostnamelarge));
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  char smallbuf[1];
+  getlogin_r (smallbuf, sizeof (loginlarge));
+  CHK_FAIL_END
+#endif
+
+  char domainnamelarge[1000];
+  int res = getdomainname (domainnamelarge, sizeof (domainnamelarge));
+#if __USE_FORTIFY_LEVEL >= 1
+  CHK_FAIL_START
+  char smallbuf[1];
+  res = getdomainname (smallbuf, sizeof (domainnamelarge));
+  CHK_FAIL_END
+#endif
+
   return ret;
 }