]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix minor memleak in edge-case of crypto_rsa.c function.
authorGeorge Kadianakis <desnacked@riseup.net>
Tue, 18 Sep 2018 11:01:15 +0000 (14:01 +0300)
committerGeorge Kadianakis <desnacked@riseup.net>
Tue, 18 Sep 2018 11:01:15 +0000 (14:01 +0300)
src/lib/crypt_ops/crypto_rsa.c

index c3c6db6c315fa17e8146b45a5e11ed5ec3858710..a510e12964f850114338031b7e914bf5f21929a3 100644 (file)
@@ -554,8 +554,10 @@ crypto_pk_read_private_key_from_filename(crypto_pk_t *env,
   char *buf = read_file_to_str(keyfile, 0, &st);
   if (!buf)
     return -1;
-  if (st.st_size > MAX_PRIVKEY_FILE_LEN)
+  if (st.st_size > MAX_PRIVKEY_FILE_LEN) {
+    tor_free(buf);
     return -1;
+  }
 
   int rv = crypto_pk_read_private_key_from_string(env, buf,
                                                   (ssize_t)st.st_size);