]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
SOCKS: Always free username/password before setting them.
authorNick Mathewson <nickm@torproject.org>
Thu, 12 Jul 2018 18:20:56 +0000 (14:20 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 12 Jul 2018 18:20:56 +0000 (14:20 -0400)
This fixes a memory leak found by fuzzing.

src/core/proto/proto_socks.c

index 530436c41bb49d7d9970bb051838f265bfadcad9..9cc9568a417b3a710a81c18aa3703568c73b3f7b 100644 (file)
@@ -174,6 +174,7 @@ parse_socks4_request(const uint8_t *raw_data, socks_request_t *req,
       goto end;
     }
 
+    tor_free(req->username);
     req->got_auth = 1;
     req->username = tor_strdup(username);
     req->usernamelen = usernamelen;
@@ -445,6 +446,7 @@ parse_socks5_userpass_auth(const uint8_t *raw_data, socks_request_t *req,
    socks5_client_userpass_auth_getconstarray_passwd(trunnel_req);
 
   if (usernamelen && username) {
+    tor_free(req->username);
     req->username = tor_memdup_nulterm(username, usernamelen);
     req->usernamelen = usernamelen;
 
@@ -452,6 +454,7 @@ parse_socks5_userpass_auth(const uint8_t *raw_data, socks_request_t *req,
   }
 
   if (passwordlen && password) {
+    tor_free(req->password);
     req->password = tor_memdup_nulterm(password, passwordlen);
     req->passwordlen = passwordlen;