From 7c52a0555aee23f171870c5d41ce3c0f593c2e57 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 26 Sep 2014 09:06:36 -0400 Subject: [PATCH] Check key_len in secret_to_key_new() 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/crypto_s2k.c b/src/common/crypto_s2k.c index 93c96e74ae..aef8436ad9 100644 --- a/src/common/crypto_s2k.c +++ b/src/common/crypto_s2k.c @@ -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;