From 02039d0ce6f8a9897495a139e5017adbae85484e Mon Sep 17 00:00:00 2001 From: "Stuart D. Gathman" Date: Sat, 18 Feb 2017 15:37:24 -0500 Subject: [PATCH] Fix problems found using gcc-7 --- cjdns.benc.patch | 22 ++++++++++++++++++++++ cjdns.entropy.patch | 9 +++++---- cjdns.python3.patch | 17 +++++++++++++++++ cjdns.spec | 11 ++++++++++- cjdns.warnings.patch | 41 ++++++++++++++++++++++++++++++----------- 5 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 cjdns.benc.patch create mode 100644 cjdns.python3.patch diff --git a/cjdns.benc.patch b/cjdns.benc.patch new file mode 100644 index 0000000..eb873e3 --- /dev/null +++ b/cjdns.benc.patch @@ -0,0 +1,22 @@ +diff -up ./benc/serialization/json/JsonBencSerializer.c.benc ./benc/serialization/json/JsonBencSerializer.c +--- ./benc/serialization/json/JsonBencSerializer.c.benc 2017-02-18 13:07:19.840276161 -0500 ++++ ./benc/serialization/json/JsonBencSerializer.c 2017-02-18 13:08:31.044121936 -0500 +@@ -72,15 +72,15 @@ static int32_t serializeString(struct Wr + Writer_write(writer, "\"", 1); + size_t i; + uint8_t chr; +- char buffer[4]; ++ char buffer[5]; + for (i = 0; i < string->len; i++) { + chr = (uint8_t) string->bytes[i] & 0xFF; + /* Nonprinting chars, \ and " are hex'd */ + if (chr < 126 && chr > 31 && chr != '\\' && chr != '"') { +- snprintf(buffer, 4, "%c", chr); ++ snprintf(buffer, 5, "%c", chr); + Writer_write(writer, buffer, 1); + } else { +- snprintf(buffer, 4, "\\x%.2X", chr); ++ snprintf(buffer, 5, "\\x%.2X", chr); + Writer_write(writer, buffer, 4); + } + } diff --git a/cjdns.entropy.patch b/cjdns.entropy.patch index 185e1a5..0177f3c 100644 --- a/cjdns.entropy.patch +++ b/cjdns.entropy.patch @@ -1,15 +1,16 @@ diff -up ./crypto/random/seed/GetEntropyRandomSeed.c.entropy ./crypto/random/seed/GetEntropyRandomSeed.c --- ./crypto/random/seed/GetEntropyRandomSeed.c.entropy 2016-10-11 17:39:44.000000000 -0400 -+++ ./crypto/random/seed/GetEntropyRandomSeed.c 2017-01-14 16:54:53.211554142 -0500 -@@ -21,7 +21,10 @@ ++++ ./crypto/random/seed/GetEntropyRandomSeed.c 2017-02-18 13:59:03.131999629 -0500 +@@ -21,7 +21,11 @@ #include #include -#ifndef __OPENBSD__ +#define GetEntropyRandomSeed_GLIBC_HAS_IT \ + (defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 25)) -+ -+#if !defined(__OPENBSD__) && !GetEntropyRandomSeed_GLIBC_HAS_IT ++/* gcc warns against using defined() inside #define, so just copy definition */ ++#if !defined(__OPENBSD__) && \ ++!(defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 25)) static int getentropy(void *buf, size_t buflen) { int ret; diff --git a/cjdns.python3.patch b/cjdns.python3.patch new file mode 100644 index 0000000..c76c490 --- /dev/null +++ b/cjdns.python3.patch @@ -0,0 +1,17 @@ +diff -up ./node_build/dependencies/libuv/gyp_uv.py.python3 ./node_build/dependencies/libuv/gyp_uv.py +--- ./node_build/dependencies/libuv/gyp_uv.py.python3 2017-02-18 15:19:22.280061575 -0500 ++++ ./node_build/dependencies/libuv/gyp_uv.py 2017-02-18 15:32:37.090478242 -0500 +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python2 + + import glob + import platform +@@ -34,6 +34,7 @@ def compiler_version(): + proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE) + version = proc.communicate()[0].split('.') + version = map(int, version[:2]) ++ if len(version) < 2: version.append(0) + version = tuple(version) + return (version, is_clang) + diff --git a/cjdns.spec b/cjdns.spec index 0e4a045..dfb6366 100644 --- a/cjdns.spec +++ b/cjdns.spec @@ -43,7 +43,7 @@ Name: cjdns # major version is cjdns protocol version: Version: 18 -Release: 5%{?dist} +Release: 6%{?dist} Summary: The privacy-friendly network without borders Group: System Environment/Base # cjdns is all GPLv3 except libuv which is MIT and BSD and ISC @@ -94,6 +94,10 @@ Patch12: cjdns.sign.patch Patch13: cjdns.ppc64.patch # getentropy(2) added to glibc in Fedora 26 Patch14: cjdns.entropy.patch +# Fix buffer overrun in JsonBencSerializer.c +Patch15: cjdns.benc.patch +# Specify python2 for systems that default to python3 +Patch16: cjdns.python3.patch BuildRequires: nodejs, nodejs-ronn, python2 @@ -209,6 +213,8 @@ fi %patch10 -b .tools %patch13 -b .ppc64 %patch14 -b .entropy +%patch15 -b .benc +%patch16 -b .python3 cp %{SOURCE1} README_Fedora.md @@ -507,6 +513,9 @@ fi %{_bindir}/graphStats %changelog +* Sat Feb 18 2017 Stuart D. Gathman 18-6 +- Fix errors and document nits found by gcc7 + * Sat Jan 7 2017 Stuart D. Gathman 18-5 - Run scripts in %{sysconfdir}/cjdns/up.d when cjdns comes up. diff --git a/cjdns.warnings.patch b/cjdns.warnings.patch index 8fc61ad..64e6543 100644 --- a/cjdns.warnings.patch +++ b/cjdns.warnings.patch @@ -1,6 +1,6 @@ diff -up ./crypto/CryptoAuth.c.warnings ./crypto/CryptoAuth.c ---- ./crypto/CryptoAuth.c.warnings 2016-01-27 03:07:49.000000000 -0500 -+++ ./crypto/CryptoAuth.c 2016-05-03 22:06:45.842528947 -0400 +--- ./crypto/CryptoAuth.c.warnings 2016-10-11 17:39:44.000000000 -0400 ++++ ./crypto/CryptoAuth.c 2017-02-18 14:33:13.145294735 -0500 @@ -77,6 +77,8 @@ static inline void getSharedSecret(uint8 uint8_t passwordHash[32], struct Log* logger) @@ -19,8 +19,8 @@ diff -up ./crypto/CryptoAuth.c.warnings ./crypto/CryptoAuth.c uint8_t myPublicKeyHex[65]; printHexPubKey(myPublicKeyHex, myPrivateKey); diff -up ./dht/CJDHTConstants.h.warnings ./dht/CJDHTConstants.h ---- ./dht/CJDHTConstants.h.warnings 2016-01-27 03:07:49.000000000 -0500 -+++ ./dht/CJDHTConstants.h 2016-05-03 22:06:45.842528947 -0400 +--- ./dht/CJDHTConstants.h.warnings 2016-10-11 17:39:44.000000000 -0400 ++++ ./dht/CJDHTConstants.h 2017-02-18 14:33:13.145294735 -0500 @@ -17,7 +17,9 @@ #include "benc/String.h" @@ -39,9 +39,28 @@ diff -up ./dht/CJDHTConstants.h.warnings ./dht/CJDHTConstants.h - +#pragma GCC diagnostic pop #endif +diff -up ./dht/dhtcore/NodeStore.c.warnings ./dht/dhtcore/NodeStore.c +--- ./dht/dhtcore/NodeStore.c.warnings 2017-02-18 14:33:47.091697196 -0500 ++++ ./dht/dhtcore/NodeStore.c 2017-02-18 14:34:03.824895582 -0500 +@@ -1752,11 +1752,15 @@ struct NodeList* NodeStore_getPeers(uint + if ((out->nodes[j]->address.path - label) > (p - label)) { continue; } + break; + } ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" + switch (j) { + default: Bits_memmove(out->nodes, &out->nodes[1], (j - 1) * sizeof(char*)); ++ // fallthrough + case 1: out->nodes[j - 1] = next->child; + case 0:; + } ++#pragma GCC diagnostic pop + } + + out->size = 0; diff -up ./node_build/dependencies/libuv/test/test-getsockname.c.warnings ./node_build/dependencies/libuv/test/test-getsockname.c ---- ./node_build/dependencies/libuv/test/test-getsockname.c.warnings 2016-01-27 03:07:49.000000000 -0500 -+++ ./node_build/dependencies/libuv/test/test-getsockname.c 2016-05-03 22:06:45.842528947 -0400 +--- ./node_build/dependencies/libuv/test/test-getsockname.c.warnings 2016-10-11 17:39:44.000000000 -0400 ++++ ./node_build/dependencies/libuv/test/test-getsockname.c 2017-02-18 14:33:13.145294735 -0500 @@ -18,7 +18,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. @@ -52,9 +71,9 @@ diff -up ./node_build/dependencies/libuv/test/test-getsockname.c.warnings ./node #include "task.h" diff -up ./util/platform/netdev/NetPlatform_linux.c.warnings ./util/platform/netdev/NetPlatform_linux.c ---- ./util/platform/netdev/NetPlatform_linux.c.warnings 2016-01-27 03:07:49.000000000 -0500 -+++ ./util/platform/netdev/NetPlatform_linux.c 2016-05-03 22:06:45.842528947 -0400 -@@ -142,7 +142,7 @@ void NetPlatform_addAddress(const char* +--- ./util/platform/netdev/NetPlatform_linux.c.warnings 2016-10-11 17:39:44.000000000 -0400 ++++ ./util/platform/netdev/NetPlatform_linux.c 2017-02-18 14:33:13.145294735 -0500 +@@ -165,7 +165,7 @@ void NetPlatform_addAddress(const char* Except_throw(eh, "ioctl(SIOCSIFADDR) failed: [%s]", strerror(err)); } @@ -64,8 +83,8 @@ diff -up ./util/platform/netdev/NetPlatform_linux.c.warnings ./util/platform/net memcpy(&sin.sin_addr, &x, 4); memcpy(&ifRequest.ifr_addr, &sin, sizeof(struct sockaddr_in)); diff -up ./util/platform/Sockaddr.c.warnings ./util/platform/Sockaddr.c ---- ./util/platform/Sockaddr.c.warnings 2016-01-27 03:07:49.000000000 -0500 -+++ ./util/platform/Sockaddr.c 2016-05-03 22:06:45.842528947 -0400 +--- ./util/platform/Sockaddr.c.warnings 2016-10-11 17:39:44.000000000 -0400 ++++ ./util/platform/Sockaddr.c 2017-02-18 14:33:13.145294735 -0500 @@ -12,6 +12,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see .