Fix HMAC to pass invalid key len test

Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
Matt Caswell 2015-02-10 13:15:25 +00:00
parent e7c2ad508d
commit ddbf312fb4

View file

@ -123,7 +123,8 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
&ctx->key_length))
goto err;
} else {
OPENSSL_assert(len >= 0 && len <= (int)sizeof(ctx->key));
if(len < 0 || len > (int)sizeof(ctx->key))
return 0;
memcpy(ctx->key, key, len);
ctx->key_length = len;
}