]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Work around a false positive in Coverity.
authorSebastian Hahn <sebastian@torproject.org>
Fri, 2 Dec 2011 05:15:31 +0000 (06:15 +0100)
committerSebastian Hahn <sebastian@torproject.org>
Fri, 2 Dec 2011 05:16:57 +0000 (06:16 +0100)
Fixes cid 501 and 502.

src/common/crypto.c

index 62b0bcec6c3b4653b9700d9a2b0d15d2b5376745..2aa3fc97a57314daa8512b8b7330544b8897c0f7 100644 (file)
@@ -1912,9 +1912,12 @@ crypto_get_stored_dynamic_dh_modulus(const char *fname)
   }
 
   /* 'fname' contains the DH parameters stored in base64-ed DER
-     format. We are only interested in the DH modulus. */
+   *  format. We are only interested in the DH modulus.
+   *  NOTE: We allocate more storage here than we need. Since we're already
+   *  doing that, we can also add 1 byte extra to appease Coverity's
+   *  scanner. */
 
-  cp = base64_decoded_dh = tor_malloc_zero(strlen(contents));
+  cp = base64_decoded_dh = tor_malloc_zero(strlen(contents) + 1);
   length = base64_decode((char *)base64_decoded_dh, strlen(contents),
                          contents, strlen(contents));
   if (length < 0) {