]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix mock_crypto_pk_public_checksig__nocheck() to handle short RSA keys
authorNick Mathewson <nickm@torproject.org>
Sat, 11 Nov 2017 19:42:39 +0000 (14:42 -0500)
committerNick Mathewson <nickm@torproject.org>
Sat, 11 Nov 2017 19:44:45 +0000 (14:44 -0500)
This function -- a mock replacement used only for fuzzing -- would
have a buffer overflow if it got an RSA key whose modulus was under
20 bytes long.

Fortunately, Tor itself does not appear to have a bug here.

Fixes bug 24247; bugfix on 0.3.0.3-alpha when fuzzing was
introduced.  Found by OSS-Fuzz; this is OSS-Fuzz issue 4177.

changes/bug24247 [new file with mode: 0644]
src/test/fuzz/fuzzing_common.c

diff --git a/changes/bug24247 b/changes/bug24247
new file mode 100644 (file)
index 0000000..1f4ddcd
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes (fuzzing):
+    - Fix a bug in our fuzzing mock replacement for crypto_pk_checksig(), to
+      correctly handle cases where a caller gives it an RSA key of under 160
+      bits. (This is not actually a bug in Tor itself, but wrather in our
+      fuzzing code.)  Fixes bug 24247; bugfix on 0.3.0.3-alpha.
+      Found by OSS-Fuzz as issue 4177.
index 7ebddde1a88ae9dfd47014c27ca4a87d1a563b98..1e98eb6c855a60428b5e6593424a217ff65acfc3 100644 (file)
@@ -28,8 +28,9 @@ mock_crypto_pk_public_checksig__nocheck(const crypto_pk_t *env, char *to,
   (void)fromlen;
   /* We could look at from[0..fromlen-1] ... */
   tor_assert(tolen >= crypto_pk_keysize(env));
-  memset(to, 0x01, 20);
-  return 20;
+  size_t siglen = MIN(20, crypto_pk_keysize(env));
+  memset(to, 0x01, siglen);
+  return (int)siglen;
 }
 
 static int