Mercurial > hg > octave-lyh > gnulib-hg
changeset 12235:1441ddf44357
stdlib-safer: wrap all mkstemp variants
* modules/mkostemp (configure.ac): Set witness.
* modules/mkostemps (configure.ac): Likewise.
* modules/mkstemps (configure.ac): Likewise.
* lib/stdlib-safer.h (mkostemp_safer, mkostemps_safer)
(mkstemps_safer): Wrap more functions.
* lib/stdlib--.h (mkostemp, mkostemps, mkstemps): Default the
wrapping.
* lib/mkstemp-safer.c (mkostemp_safer, mkostemps_safer)
(mkstemps_safer): Implement the wrappers.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 02 Nov 2009 16:11:18 -0700 |
parents | b45701f2ff71 |
children | 192e34a06bb4 |
files | ChangeLog lib/mkstemp-safer.c lib/stdlib--.h lib/stdlib-safer.h modules/mkostemp modules/mkostemps modules/mkstemps |
diffstat | 7 files changed, 70 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2009-11-04 Eric Blake <ebb9@byu.net> + stdlib-safer: wrap all mkstemp variants + * modules/mkostemp (configure.ac): Set witness. + * modules/mkostemps (configure.ac): Likewise. + * modules/mkstemps (configure.ac): Likewise. + * lib/stdlib-safer.h (mkostemp_safer, mkostemps_safer) + (mkstemps_safer): Wrap more functions. + * lib/stdlib--.h (mkostemp, mkostemps, mkstemps): Default the + wrapping. + * lib/mkstemp-safer.c (mkostemp_safer, mkostemps_safer) + (mkstemps_safer): Implement the wrappers. + mkstemps, mkostemps: new modules * modules/mkostemps: New module. * modules/mkstemps: Likewise.
--- a/lib/mkstemp-safer.c +++ b/lib/mkstemp-safer.c @@ -1,6 +1,6 @@ /* Invoke mkstemp, but avoid some glitches. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 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 @@ -32,3 +32,32 @@ { return fd_safer (mkstemp (templ)); } + +#if GNULIB_MKOSTEMP +/* Like mkostemp, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int +mkostemp_safer (char *templ, int flags) +{ + return fd_safer (mkostemp (templ, flags)); +} +#endif + +#if GNULIB_MKOSTEMPS +/* Like mkostemps, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int +mkostemps_safer (char *templ, int suffixlen, int flags) +{ + return fd_safer (mkostemps (templ, suffixlen, flags)); +} +#endif + +#if GNULIB_MKSTEMPS +/* Like mkstemps, but do not return STDIN_FILENO, STDOUT_FILENO, or + STDERR_FILENO. */ +int mkstemps_safer (char *templ, int suffixlen) +{ + return fd_safer (mkstemps (templ, suffixlen)); +} +#endif
--- a/lib/stdlib--.h +++ b/lib/stdlib--.h @@ -1,6 +1,6 @@ /* Like stdlib.h, but redefine some names to avoid glitches. - Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2006, 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 @@ -22,3 +22,15 @@ #undef mkstemp #define mkstemp mkstemp_safer + +#if GNULIB_MKOSTEMP +# define mkostemp mkostemp_safer +#endif + +#if GNULIB_MKOSTEMPS +# define mkostemps mkostemps_safer +#endif + +#if GNULIB_MKSTEMPS +# define mkstemps mkstemps_safer +#endif
--- a/lib/stdlib-safer.h +++ b/lib/stdlib-safer.h @@ -1,6 +1,6 @@ /* Invoke stdlib.h functions, but avoid some glitches. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 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 @@ -18,3 +18,15 @@ /* Written by Paul Eggert. */ int mkstemp_safer (char *); + +#if GNULIB_MKOSTEMP +int mkostemp_safer (char *, int); +#endif + +#if GNULIB_MKOSTEMPS +int mkostemps_safer (char *, int, int); +#endif + +#if GNULIB_MKSTEMPS +int mkstemps_safer (char *, int); +#endif
--- a/modules/mkostemp +++ b/modules/mkostemp @@ -13,6 +13,7 @@ configure.ac: gl_FUNC_MKOSTEMP +gl_MODULE_INDICATOR([mkostemp]) gl_STDLIB_MODULE_INDICATOR([mkostemp]) Makefile.am: