diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-07-13 06:09:58 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-07-13 06:09:58 +0000 |
commit | b799f91dddb33467760c260e67d9cd86f53a829c (patch) | |
tree | 2aed3cc5c3968b4041938f0c4d3146ff45600090 /debug/tst-chk1.c | |
parent | 9d653cd1893cdd0a073b8aef3f2d8f7626d778df (diff) | |
download | glibc-b799f91dddb33467760c260e67d9cd86f53a829c.tar.gz glibc-b799f91dddb33467760c260e67d9cd86f53a829c.tar.xz glibc-b799f91dddb33467760c260e67d9cd86f53a829c.zip |
* stdlib/bits/stdlib.h: New file.
* stdlib/stdlib.h: Include <bits/stdlib.h> if fortification is requested. * Makefile (headers): Add bits/stdlib.h. * include/bits/stdlib.h: New file. * debug/Depend: New file. * debug/ptsname_r_chk.c: New file. * debug/realpath_chk.c: New file. * debug/wctomb_chk.c: New file. * debug/Makefile (routines): Add ptsname_r_chk, realpath_chk, and wctomb_chk. * debug/Versions: Export __ptsname_r_chk, __realpath_chk, and __wctomb_chk. * debug/tst-chk1.c: Add tests for __ptsname_r_chk, __realpath_chk, and __wctomb_chk.
Diffstat (limited to 'debug/tst-chk1.c')
-rw-r--r-- | debug/tst-chk1.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c index 6389d1150e..ba50973868 100644 --- a/debug/tst-chk1.c +++ b/debug/tst-chk1.c @@ -18,6 +18,7 @@ 02111-1307 USA. */ #include <fcntl.h> +#include <locale.h> #include <paths.h> #include <setjmp.h> #include <signal.h> @@ -791,5 +792,69 @@ do_test (void) if (rmdir (fname) != 0) FAIL (); + +#if PATH_MAX > 0 + char largebuf[PATH_MAX]; + char *realres = realpath (".", largebuf); +#endif +#if __USE_FORTIFY_LEVEL >= 1 + CHK_FAIL_START + char realbuf[1]; + realres = realpath (".", realbuf); + CHK_FAIL_END +#endif + + if (setlocale (LC_ALL, "de_DE.UTF-8") != NULL) + { + /* First a simple test. */ + char enough[MB_CUR_MAX]; + if (wctomb (enough, L'A') != 1) + { + puts ("first wctomb test failed"); + ret = 1; + } + +#if __USE_FORTIFY_LEVEL >= 1 + /* We know the wchar_t encoding is ISO 10646. So pick a + character which has a multibyte representation which does not + fit. */ + CHK_FAIL_START + char smallbuf[2]; + if (wctomb (smallbuf, L'\x100') != 2) + { + puts ("second wctomb test failed"); + ret = 1; + } + CHK_FAIL_END +#endif + } + else + { + puts ("cannot set locale"); + ret = 1; + } + + fd = posix_openpt (O_RDWR); + if (fd != -1) + { + char enough[1000]; + if (ptsname_r (fd, enough, sizeof (enough)) != 0) + { + puts ("first ptsname_r failed"); + ret = 1; + } + +#if __USE_FORTIFY_LEVEL >= 1 + CHK_FAIL_START + char smallbuf[2]; + if (ptsname_r (fd, smallbuf, sizeof (smallbuf) + 1) == 0) + { + puts ("second ptsname_r somehow suceeded"); + ret = 1; + } + CHK_FAIL_END +#endif + } + return ret; } |