From fb8c836ade0d4ab8050c2c381795ce098b701115 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 19 Aug 2009 09:54:54 -0600 Subject: [PATCH] tests: test some of the *-safer modules * modules/fopen-safer (Depends-on): Add fopen. * modules/fcntl-safer (Depends-on): Add fcntl. * modules/stdlib-safer (Depends-on): Add stdlib. (configure.ac): Set indicator. * modules/unistd-safer (configure.ac): Likewise. * modules/tmpfile-safer (configure.ac): Likewise. (Depends-on): Add tmpfile. * lib/stdio--.h (fopen, tmpfile): Don't override unless module is active. * tests/test-fopen.c (includes): Test safer versions when they are in use. * tests/test-open.c (includes): Likewise. Signed-off-by: Eric Blake --- ChangeLog | 14 ++++++++++++++ lib/stdio--.h | 14 +++++++++----- modules/fcntl-safer | 1 + modules/fopen-safer | 1 + modules/stdlib-safer | 2 ++ modules/tmpfile-safer | 2 ++ modules/unistd-safer | 1 + tests/test-fopen.c | 6 +++++- tests/test-open.c | 4 ++++ 9 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a545c696..b5d16e644 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2009-08-19 Eric Blake + tests: test some of the *-safer modules + * modules/fopen-safer (Depends-on): Add fopen. + * modules/fcntl-safer (Depends-on): Add fcntl. + * modules/stdlib-safer (Depends-on): Add stdlib. + (configure.ac): Set indicator. + * modules/unistd-safer (configure.ac): Likewise. + * modules/tmpfile-safer (configure.ac): Likewise. + (Depends-on): Add tmpfile. + * lib/stdio--.h (fopen, tmpfile): Don't override unless module is + active. + * tests/test-fopen.c (includes): Test safer versions when they are + in use. + * tests/test-open.c (includes): Likewise. + popen: fix cygwin 1.5 bug when stdin closed * doc/posix-functions/popen.texi (popen): Document cygwin bugs. * modules/popen: New file. diff --git a/lib/stdio--.h b/lib/stdio--.h index 39fca2920..eafbdb127 100644 --- a/lib/stdio--.h +++ b/lib/stdio--.h @@ -1,6 +1,6 @@ /* Like stdio.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,8 +20,12 @@ #include #include "stdio-safer.h" -#undef fopen -#define fopen fopen_safer +#if GNULIB_FOPEN_SAFER +# undef fopen +# define fopen fopen_safer +#endif -#undef tmpfile -#define tmpfile tmpfile_safer +#if GNULIB_TMPFILE_SAFER +# undef tmpfile +# define tmpfile tmpfile_safer +#endif diff --git a/modules/fcntl-safer b/modules/fcntl-safer index 253b76b44..b9da46608 100644 --- a/modules/fcntl-safer +++ b/modules/fcntl-safer @@ -10,6 +10,7 @@ m4/fcntl-safer.m4 m4/mode_t.m4 Depends-on: +fcntl open unistd-safer diff --git a/modules/fopen-safer b/modules/fopen-safer index 087e045c2..6a68f0cde 100644 --- a/modules/fopen-safer +++ b/modules/fopen-safer @@ -8,6 +8,7 @@ lib/fopen-safer.c m4/stdio-safer.m4 Depends-on: +fopen unistd-safer configure.ac: diff --git a/modules/stdlib-safer b/modules/stdlib-safer index 8f7cb3f00..ddeb865ac 100644 --- a/modules/stdlib-safer +++ b/modules/stdlib-safer @@ -9,10 +9,12 @@ m4/stdlib-safer.m4 Depends-on: mkstemp +stdlib unistd-safer configure.ac: gl_STDLIB_SAFER +gl_MODULE_INDICATOR([stdlib-safer]) Makefile.am: diff --git a/modules/tmpfile-safer b/modules/tmpfile-safer index c81906332..de615442e 100644 --- a/modules/tmpfile-safer +++ b/modules/tmpfile-safer @@ -9,10 +9,12 @@ m4/stdio-safer.m4 Depends-on: binary-io +tmpfile unistd-safer configure.ac: gl_TMPFILE_SAFER +gl_MODULE_INDICATOR([tmpfile-safer]) Makefile.am: diff --git a/modules/unistd-safer b/modules/unistd-safer index 86e23abe0..e2182fd14 100644 --- a/modules/unistd-safer +++ b/modules/unistd-safer @@ -14,6 +14,7 @@ unistd configure.ac: gl_UNISTD_SAFER +gl_MODULE_INDICATOR([unistd-safer]) Makefile.am: diff --git a/tests/test-fopen.c b/tests/test-fopen.c index 337a38919..b9e369407 100644 --- a/tests/test-fopen.c +++ b/tests/test-fopen.c @@ -1,5 +1,5 @@ /* Test of opening a file stream. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +21,10 @@ #include #include +#if GNULIB_FOPEN_SAFER +# include "stdio--.h" +#endif + #define ASSERT(expr) \ do \ { \ diff --git a/tests/test-open.c b/tests/test-open.c index f7bb54360..c9f3641c3 100644 --- a/tests/test-open.c +++ b/tests/test-open.c @@ -23,6 +23,10 @@ #include #include +#if GNULIB_FCNTL_SAFER +# include "fcntl--.h" +#endif + #define ASSERT(expr) \ do \ { \ -- 2.11.0