From 7ace8d5a61f75fb77e3619deed417edd5610a4f1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 18 Sep 2018 14:43:57 -0400 Subject: Assert that some trunnel _new() functions return non-NULL The trunnel functions are written under the assumption that their allocators can fail, so GCC LTO thinks they might return NULL. In point of fact, they're using tor_malloc() and friends, which can't fail, but GCC won't necessarily figure that out. Fixes part of #27772. --- src/core/proto/proto_socks.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/core/proto') diff --git a/src/core/proto/proto_socks.c b/src/core/proto/proto_socks.c index ccf96f7814..e2f233ad05 100644 --- a/src/core/proto/proto_socks.c +++ b/src/core/proto/proto_socks.c @@ -353,6 +353,7 @@ process_socks5_methods_request(socks_request_t *req, int have_user_pass, { socks_result_t res = SOCKS_RESULT_DONE; socks5_server_method_t *trunnel_resp = socks5_server_method_new(); + tor_assert(trunnel_resp); socks5_server_method_set_version(trunnel_resp, SOCKS_VER_5); @@ -478,6 +479,7 @@ process_socks5_userpass_auth(socks_request_t *req) socks_result_t res = SOCKS_RESULT_DONE; socks5_server_userpass_auth_t *trunnel_resp = socks5_server_userpass_auth_new(); + tor_assert(trunnel_resp); if (req->socks_version != SOCKS_VER_5) { res = SOCKS_RESULT_INVALID; @@ -869,6 +871,7 @@ socks_request_set_socks5_error(socks_request_t *req, socks5_reply_status_t reason) { socks5_server_reply_t *trunnel_resp = socks5_server_reply_new(); + tor_assert(trunnel_resp); socks5_server_reply_set_version(trunnel_resp, SOCKS_VER_5); socks5_server_reply_set_reply(trunnel_resp, reason); -- cgit v1.2.3-54-g00ecf From dddecee291cadf391d93b569023f1f1e008880e8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 18 Sep 2018 15:13:10 -0400 Subject: Initialize some locals in socks5 parsing code. These confused GCC LTO, which thought they might be used uninitialized. I'm pretty sure that as long as 'res' indicates success, they will always be set to something, but let's unconfuse the compiler in any case. --- src/core/proto/proto_socks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/proto') diff --git a/src/core/proto/proto_socks.c b/src/core/proto/proto_socks.c index e2f233ad05..e23da7730b 100644 --- a/src/core/proto/proto_socks.c +++ b/src/core/proto/proto_socks.c @@ -744,7 +744,7 @@ handle_socks_message(const uint8_t *raw_data, size_t datalen, res = SOCKS_RESULT_MORE_EXPECTED; goto end; } else if (req->socks_version != SOCKS_VER_5) { - int have_user_pass, have_no_auth; + int have_user_pass=0, have_no_auth=0; res = parse_socks5_methods_request(raw_data, req, datalen, &have_user_pass, &have_no_auth, -- cgit v1.2.3-54-g00ecf