Fix undefined behaviour on build with -D_FORTIFY_SOURCE=2
Found by tstellar@redhat.com
This commit is contained in:
parent
18772bf568
commit
af4cd47b9f
51
memcached-1.6.3-dfortify.patch
Normal file
51
memcached-1.6.3-dfortify.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From c65973d08c4dffbb38ce032d00b901d0ce534c6f Mon Sep 17 00:00:00 2001
|
||||
From: Tom Stellard <tstellar@redhat.com>
|
||||
Date: Mon, 30 Mar 2020 17:49:38 +0000
|
||||
Subject: [PATCH] Fix undefined behavior when compiling with
|
||||
-D_FORTIFY_SOURCE=2
|
||||
|
||||
When compiling with -D_FORTIFY_SOURCE=2, printf is defined as a macro,
|
||||
which makes the #ifdef TLS block in the usage() function of memcached.c
|
||||
undefined behavior.
|
||||
|
||||
This warning was caught by compiling with clang:
|
||||
|
||||
memcached.c:7829:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
|
||||
^
|
||||
memcached.c:7832:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
|
||||
^
|
||||
---
|
||||
memcached.c | 11 ++++++-----
|
||||
1 file changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/memcached.c b/memcached.c
|
||||
index 2592b3f94..148a3b55a 100644
|
||||
--- a/memcached.c
|
||||
+++ b/memcached.c
|
||||
@@ -7825,12 +7825,13 @@ static void usage(void) {
|
||||
"-s, --unix-socket=<file> UNIX socket to listen on (disables network support)\n"
|
||||
"-A, --enable-shutdown enable ascii \"shutdown\" command\n"
|
||||
"-a, --unix-mask=<mask> access mask for UNIX socket, in octal (default: %o)\n"
|
||||
- "-l, --listen=<addr> interface to listen on (default: INADDR_ANY)\n"
|
||||
+ "-l, --listen=<addr> interface to listen on (default: INADDR_ANY)\n",
|
||||
+ settings.port, settings.udpport, settings.access);
|
||||
#ifdef TLS
|
||||
- " if TLS/SSL is enabled, 'notls' prefix can be used to\n"
|
||||
- " disable for specific listeners (-l notls:<ip>:<port>) \n"
|
||||
+ printf(" if TLS/SSL is enabled, 'notls' prefix can be used to\n"
|
||||
+ " disable for specific listeners (-l notls:<ip>:<port>) \n");
|
||||
#endif
|
||||
- "-d, --daemon run as a daemon\n"
|
||||
+ printf("-d, --daemon run as a daemon\n"
|
||||
"-r, --enable-coredumps maximize core file limit\n"
|
||||
"-u, --user=<user> assume identity of <username> (only when run as root)\n"
|
||||
"-m, --memory-limit=<num> item memory in megabytes (default: %lu)\n"
|
||||
@@ -7846,7 +7847,7 @@ static void usage(void) {
|
||||
"-P, --pidfile=<file> save PID in <file>, only used with -d option\n"
|
||||
"-f, --slab-growth-factor=<num> chunk size growth factor (default: %2.2f)\n"
|
||||
"-n, --slab-min-size=<bytes> min space used for key+value+flags (default: %d)\n",
|
||||
- settings.port, settings.udpport, settings.access, (unsigned long) settings.maxbytes / (1 << 20),
|
||||
+ (unsigned long) settings.maxbytes / (1 << 20),
|
||||
settings.maxconns, settings.factor, settings.chunk_size);
|
||||
verify_default("udp-port",settings.udpport == 0);
|
||||
printf("-L, --enable-largepages try to use large memory pages (if available)\n");
|
@ -12,7 +12,7 @@
|
||||
|
||||
Name: memcached
|
||||
Version: 1.6.3
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Epoch: 0
|
||||
Summary: High Performance, Distributed Memory Object Cache
|
||||
|
||||
@ -24,6 +24,7 @@ Source1: memcached.sysconfig
|
||||
Source2: https://releases.pagure.org/memcached-selinux/memcached-selinux-1.0.2.tar.gz
|
||||
|
||||
Patch1: memcached-unit.patch
|
||||
Patch2: memcached-1.6.3-dfortify.patch
|
||||
|
||||
BuildRequires: gcc libevent-devel systemd
|
||||
BuildRequires: perl-generators
|
||||
@ -68,6 +69,7 @@ optimised for use with this version of memcached.
|
||||
# and SELinux policy sources into memcached-selinux-X.X
|
||||
%setup -q -b 2
|
||||
%patch1 -p1 -b .unit
|
||||
%patch2 -p1 -b .dfortify
|
||||
|
||||
%build
|
||||
%configure \
|
||||
@ -173,6 +175,10 @@ fi
|
||||
%license ../%{selinuxmoduledir}/COPYING
|
||||
|
||||
%changelog
|
||||
* Mon Apr 06 2020 Tomas Korbar <tkorbar@redhat.com> - 0:1.6.3-2
|
||||
- Fix undefined behaviour on build with -D_FORTIFY_SOURCE=2
|
||||
- Found by tstellar@redhat.com
|
||||
|
||||
* Sun Mar 29 2020 Tomas Korbar <tkorbar@redhat.com> - 0:1.6.3-1
|
||||
- Update to 1.6.3
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user