]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/evp_test.c: Fixed strcmp() fault in mac_test_init()
authorRichard Levitte <levitte@openssl.org>
Mon, 29 Oct 2018 15:27:43 +0000 (16:27 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 29 Oct 2018 18:06:25 +0000 (19:06 +0100)
When wanting to compare the end of a string with another string, make
sure not to start somewhere before the start of the first string.

[extended tests]

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7520)

test/evp_test.c

index 311814b1bd6d22b03cde022abd88ad403df93789..25b10d331434e131393658fb5a7d9ee15bb4cbd8 100644 (file)
@@ -863,7 +863,8 @@ static int mac_test_init(EVP_TEST *t, const char *alg)
         size_t sz = strlen(alg);
         static const char epilogue[] = " by EVP_PKEY";
 
-        if (strcmp(alg + sz - (sizeof(epilogue) - 1), epilogue) == 0)
+        if (sz >= sizeof(epilogue)
+            && strcmp(alg + sz - (sizeof(epilogue) - 1), epilogue) == 0)
             sz -= sizeof(epilogue) - 1;
 
         if (strncmp(alg, "HMAC", sz) == 0) {