Fix building with glibc-2.16.6

This commit is contained in:
Petr Písař 2012-08-02 17:54:52 +02:00
parent 881eed6b4d
commit bb4f349d71
2 changed files with 99 additions and 1 deletions

View File

@ -0,0 +1,88 @@
From 5de88fad8cc214f07082445c6bb7b83091d664e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 2 Aug 2012 17:40:55 +0200
Subject: [PATCH] Fix building with glibc-2.16.6
Ported to sharutils-4.11.1 from gnulib commit:
From 66712c23388e93e5c518ebc8515140fa0c807348 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
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.
---
lib/stdio.in.h | 12 +++++++-----
m4/stdio_h.m4 | 4 ++--
m4/warn-on-use.m4 | 4 ++--
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 57e93ba..6ab9c8b 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -176,10 +176,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@
@@ -902,9 +904,9 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
# endif
#endif
-/* Some people would argue that sprintf should be handled like gets
- (for example, OpenBSD issues a link warning for both functions),
- since both can cause security holes due to buffer overruns.
+/* Some people would argue that all sprintf uses should be warned about
+ (for example, OpenBSD issues a link warning for it),
+ since it can cause security holes due to buffer overruns.
However, we believe that sprintf can be used safely, and is more
efficient than snprintf in those safe cases; and as proof of our
belief, we use sprintf in several gnulib modules. So this header
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 7f3ae56..990c616 100644
--- a/m4/stdio_h.m4
+++ b/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 <stdio.h>
- ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
+ ]], [dprintf fpurge fseeko ftello getdelim getline gets popen renameat
snprintf tmpfile vdprintf vsnprintf])
])
diff --git a/m4/warn-on-use.m4 b/m4/warn-on-use.m4
index e0d0f27..4b07efb 100644
--- a/m4/warn-on-use.m4
+++ b/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],
[
--
1.7.11.2

View File

@ -1,12 +1,16 @@
Summary: The GNU shar utilities for packaging and unpackaging shell archives
Name: sharutils
Version: 4.11.1
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+ and LGPLv2+ and Public Domain
Group: Applications/Archiving
Source: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2
# Adjust bundled gnulib to pass compilation with glibc-2.16.6
Patch0: sharutils-4.11.1-Fix-building-with-glibc-2.16.6.patch
URL: http://www.gnu.org/software/%{name}/
BuildRequires: gettext
# For sharutils-4.11.1-Fix-building-with-glibc-2.16.6.patch:
BuildRequires: autoconf, automake
Requires(post): info
Requires(preun): info
Provides: bundled(gnulib)
@ -26,6 +30,9 @@ shar files.
%prep
%setup -q
# For sharutils-4.11.1-Fix-building-with-glibc-2.16.6.patch
%patch0 -p1 -b .gnulib_gets
autoreconf
# convert TODO, THANKS to UTF-8
for i in TODO THANKS; do
@ -66,6 +73,9 @@ fi
%{_mandir}/man5/*
%changelog
* Thu Aug 02 2012 Petr Pisar <ppisar@redhat.com> - 4.11.1-5
- Fix building with glibc-2.16.6
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 4.11.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild