Commit 88e3cf0a authored by Richard Levitte's avatar Richard Levitte
Browse files

test/evp_test.c: Fixed strcmp() fault in mac_test_init()



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: default avatarMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7520)
parent ce5d64c7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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) {