From 8f71a809890bb14e2d5bf0cf391423097ce0247c Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 23 Feb 2015 17:44:12 +0100 Subject: [PATCH] security/obfsclient: Backport upstream fixes for compiler complaints Expected to fix FreeBSD bug #197909. --- security/obfsclient/files/patch-crypto-ctr.h | 42 ++++++++++++++++++++++ security/obfsclient/files/patch-ext-optionparser.h | 31 ++++++++++++++++ .../obfsclient/files/patch-scramblesuit-client.cc | 30 ++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 security/obfsclient/files/patch-crypto-ctr.h create mode 100644 security/obfsclient/files/patch-ext-optionparser.h create mode 100644 security/obfsclient/files/patch-scramblesuit-client.cc diff --git a/security/obfsclient/files/patch-crypto-ctr.h b/security/obfsclient/files/patch-crypto-ctr.h new file mode 100644 index 0000000..525d9d6 --- /dev/null +++ b/security/obfsclient/files/patch-crypto-ctr.h @@ -0,0 +1,42 @@ +From c91f7bbf3e0eedb080319ba3cfed7b47597b5aeb Mon Sep 17 00:00:00 2001 +From: Yawning Angel +Date: Sun, 20 Apr 2014 16:52:06 +0000 +Subject: Fix a potential bug found by clang's scan-build. + +With all current uses of Ctr, the conditional I was missing is never +triggered since the paramenters are guaranteed to be sane, but this is +not guaranteed to be true in the future. + +scan-build also points out a bunch of things in easylogging++ and gtest +but they don't look to be real problems. +--- + ChangeLog | 2 ++ [diff removed] + src/schwanenlied/crypto/ctr.h | 5 ++++- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/schwanenlied/crypto/ctr.h b/src/schwanenlied/crypto/ctr.h +index 79bb71b..92d932d 100644 +--- src/schwanenlied/crypto/ctr.h ++++ src/schwanenlied/crypto/ctr.h +@@ -91,6 +91,8 @@ class Ctr { + return false; + if (ctr_len == 0) + return false; ++ if ((iv == nullptr && iv_len != 0) || (iv != nullptr && iv_len == 0)) ++ return false; + if (ctr_len + iv_len != ecb_impl_.block_length()) + return false; + +@@ -100,7 +102,8 @@ class Ctr { + return false; + + iv_size_ = iv_len; +- ::std::memcpy(&ctr_[0], iv, iv_len); ++ if (iv != nullptr) ++ ::std::memcpy(&ctr_[0], iv, iv_len); + ::std::memcpy(&ctr_[iv_len], ctr, ctr_len); + + has_state_ = true; +-- +2.3.0 + diff --git a/security/obfsclient/files/patch-ext-optionparser.h b/security/obfsclient/files/patch-ext-optionparser.h new file mode 100644 index 0000000..0cc58e8 --- /dev/null +++ b/security/obfsclient/files/patch-ext-optionparser.h @@ -0,0 +1,31 @@ +From 85dd63b32a0b77c57cbae224f7862a5fb9c069a8 Mon Sep 17 00:00:00 2001 +From: Yawning Angel +Date: Sat, 14 Jun 2014 22:42:35 +0000 +Subject: Fix build on GCC 4.9.0. + +Just potentially uninitialized warnings in the 3rd party command line +option parsing code, probably spurious and should be ignored but, +initialize them for now. +--- + src/ext/optionparser.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/ext/optionparser.h b/src/ext/optionparser.h +index 17bf6ad..64e2dfc 100644 +--- src/ext/optionparser.h ++++ src/ext/optionparser.h +@@ -1554,9 +1554,9 @@ inline bool Parser::workhorse(bool gnu, const Descriptor usage[], int numargs, c + + do // loop over short options in group, for long options the body is executed only once + { +- int idx; ++ int idx = 0; + +- const char* optarg; ++ const char* optarg = 0; + + /******************** long option **********************/ + if (handle_short_options == false || try_single_minus_longopt) +-- +2.3.0 + diff --git a/security/obfsclient/files/patch-scramblesuit-client.cc b/security/obfsclient/files/patch-scramblesuit-client.cc new file mode 100644 index 0000000..528b357 --- /dev/null +++ b/security/obfsclient/files/patch-scramblesuit-client.cc @@ -0,0 +1,30 @@ +From 9c164b2afb666d0bcd26ba3eeb6da07a9fff551c Mon Sep 17 00:00:00 2001 +From: Yawning Angel +Date: Sat, 14 Jun 2014 23:09:08 +0000 +Subject: Suppress more useless warnings. + +Apparently I forgot to check the IAT code when I switched to building +wiht -Wextra, since no one should use it. +--- + src/schwanenlied/pt/scramblesuit/client.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/schwanenlied/pt/scramblesuit/client.cc b/src/schwanenlied/pt/scramblesuit/client.cc +index e967b7b..c6e1a20 100644 +--- src/schwanenlied/pt/scramblesuit/client.cc ++++ src/schwanenlied/pt/scramblesuit/client.cc +@@ -468,8 +468,10 @@ bool Client::schedule_iat_transmit() { + // Lazy timer initialization + if (iat_timer_ev_ == nullptr) { + event_callback_fn cb = [](evutil_socket_t sock, +- short witch, ++ short which, + void* arg) { ++ (void)sock; ++ (void)which; + reinterpret_cast(arg)->on_iat_transmit(); + }; + iat_timer_ev_ = evtimer_new(base_, cb, this); +-- +2.3.0 + -- 2.3.0