From f5fab01434b096b3bc2b058fec41123392eb3dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Wed, 8 Aug 2012 14:13:16 +0200 Subject: [PATCH] Fix building with glibc-2.16.6 Ported to libprelude-1.0.0 from gnulib commit: From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Thu, 29 Mar 2012 13:30:41 -0600 Subject: [PATCH] stdio: don't assume gets any more Gnulib intentionally does not have a gets module, and now that C11 and glibc have dropped it, we should be more proactive about warning any user on a platform that still has a declaration of this dangerous interface. --- libmissing/m4/stdio_h.m4 | 4 ++-- libmissing/m4/warn-on-use.m4 | 4 ++-- libmissing/stdio.in.h | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libmissing/m4/stdio_h.m4 b/libmissing/m4/stdio_h.m4 index 781fa8d..fc65d37 100644 --- a/libmissing/m4/stdio_h.m4 +++ b/libmissing/m4/stdio_h.m4 @@ -34,9 +34,9 @@ AC_DEFUN([gl_STDIO_H], dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use, and which is not - dnl guaranteed by C89. + dnl guaranteed by both C89 and C11. gl_WARN_ON_USE_PREPARE([[#include - ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat + ]], [dprintf fpurge fseeko ftello getdelim getline gets popen renameat snprintf vdprintf vsnprintf]) ]) diff --git a/libmissing/m4/warn-on-use.m4 b/libmissing/m4/warn-on-use.m4 index ab46422..494e00b 100644 --- a/libmissing/m4/warn-on-use.m4 +++ b/libmissing/m4/warn-on-use.m4 @@ -18,8 +18,8 @@ dnl with or without modifications, as long as this notice is preserved. # some systems declare functions in the wrong header, then INCLUDES # should do likewise. # -# If you assume C89, then it is generally safe to assume declarations -# for functions declared in that standard (such as gets) without +# It is generally safe to assume declarations for functions declared +# in the intersection of C89 and C11 (such as printf) without # needing gl_WARN_ON_USE_PREPARE. AC_DEFUN([gl_WARN_ON_USE_PREPARE], [ diff --git a/libmissing/stdio.in.h b/libmissing/stdio.in.h index f5d5d88..6924ef2 100644 --- a/libmissing/stdio.in.h +++ b/libmissing/stdio.in.h @@ -114,10 +114,12 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " #endif /* It is very rare that the developer ever has full control of stdin, - so any use of gets warrants an unconditional warning. Assume it is - always declared, since it is required by C89. */ + so any use of gets warrants an unconditional warning; besides, C11 + removed it. */ #undef gets +#if HAVE_RAW_DECL_GETS _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); +#endif #if @GNULIB_FOPEN@ # if @REPLACE_FOPEN@ -- 1.7.11.2