]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check key_len in secret_to_key_new()
authorNick Mathewson <nickm@torproject.org>
Fri, 26 Sep 2014 13:06:36 +0000 (09:06 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 26 Sep 2014 13:06:36 +0000 (09:06 -0400)
This bug shouldn't be reachable so long as secret_to_key_len and
secret_to_key_make_specifier stay in sync, but we might screw up
someday.

Found by coverity; this is CID 1241500

src/common/crypto_s2k.c

index 93c96e74aed958fe916c70254af969313b287e2d..aef8436ad968a92fc95bdc22d2bc38ff01c75a3e 100644 (file)
@@ -392,6 +392,9 @@ secret_to_key_new(uint8_t *buf,
   type = buf[0];
   key_len = secret_to_key_key_len(type);
 
+  if (key_len < 0)
+    return key_len;
+
   if ((int)buf_len < key_len + spec_len)
     return S2K_TRUNCATED;