stdlib-safer: wrap all mkstemp variants
authorEric Blake <ebb9@byu.net>
Mon, 2 Nov 2009 23:11:18 +0000 (16:11 -0700)
committerEric Blake <ebb9@byu.net>
Thu, 5 Nov 2009 02:10:16 +0000 (19:10 -0700)
* 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>
ChangeLog
lib/mkstemp-safer.c
lib/stdlib--.h
lib/stdlib-safer.h
modules/mkostemp
modules/mkostemps
modules/mkstemps

index 34952e2..fdfd828 100644 (file)
--- 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.
index 4ba97c3..95d315b 100644 (file)
@@ -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 @@ mkstemp_safer (char *templ)
 {
   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
index 495d0eb..91268c9 100644 (file)
@@ -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
 
 #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
index a014372..c28897c 100644 (file)
@@ -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
 /* 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
index e336b90..8a61dbe 100644 (file)
@@ -13,6 +13,7 @@ tempname
 
 configure.ac:
 gl_FUNC_MKOSTEMP
+gl_MODULE_INDICATOR([mkostemp])
 gl_STDLIB_MODULE_INDICATOR([mkostemp])
 
 Makefile.am:
index 54c55e6..a4175bd 100644 (file)
@@ -13,6 +13,7 @@ tempname
 
 configure.ac:
 gl_FUNC_MKOSTEMPS
+gl_MODULE_INDICATOR([mkostemps])
 gl_STDLIB_MODULE_INDICATOR([mkostemps])
 
 Makefile.am:
index 14f4698..2a49777 100644 (file)
@@ -12,6 +12,7 @@ tempname
 
 configure.ac:
 gl_FUNC_MKSTEMPS
+gl_MODULE_INDICATOR([mkstemps])
 gl_STDLIB_MODULE_INDICATOR([mkstemps])
 
 Makefile.am: