This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Warn when using mktemp
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: newlib at sourceware dot org
- Date: Fri, 13 Mar 2009 18:53:08 +0100
- Subject: [PATCH] Warn when using mktemp
- Reply-to: newlib at sourceware dot org
Hi,
the below patch just adds a compile time warning when an application
is about to use the mktemp function, which is considered dangerous
(to quote from the Linux man page: "Never use mktemp()" :))
Ok to check in?
Corinna
* libc/include/stdlib.h (mktemp): Warn when using.
Index: libc/include/stdlib.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdlib.h,v
retrieving revision 1.28
diff -u -p -r1.28 stdlib.h
--- libc/include/stdlib.h 19 Nov 2008 20:55:52 -0000 1.28
+++ libc/include/stdlib.h 13 Mar 2009 17:51:22 -0000
@@ -98,7 +98,8 @@ size_t _EXFUN(_wcstombs_r,(struct _reent
#ifndef __STRICT_ANSI__
#ifndef _REENT_ONLY
int _EXFUN(mkstemp,(char *));
-char * _EXFUN(mktemp,(char *));
+char * _EXFUN(mktemp,(char *)) _ATTRIBUTE ((warning ("the use of `mktemp' is da
+ngerous, better use `mkstemp'")));
#endif
#endif
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat