test/evp_test.c:1238: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64.
Showing all 3 steps of the trace


test/evp_test.c:1125:5: <LHS trace>
1123.       int i;
1124.       OSSL_PARAM params[21];
1125.       size_t params_n = 0;
            ^
1126.       size_t params_n_allocstart = 0;
1127.       const OSSL_PARAM *defined_params =

test/evp_test.c:1125:5: Assignment
1123.       int i;
1124.       OSSL_PARAM params[21];
1125.       size_t params_n = 0;
            ^
1126.       size_t params_n_allocstart = 0;
1127.       const OSSL_PARAM *defined_params =

test/evp_test.c:1238:12: Binary operation: ([0, +oo] - 1):unsigned64
1236.       t->err = NULL;
1237.    err:
1238.       while (params_n-- > params_n_allocstart) {
                   ^
1239.           OPENSSL_free(params[params_n].data);
1240.       }

static int mac_test_run_mac(EVP_TEST *t)
{
    MAC_DATA *expected = t->data;
    EVP_MAC_CTX *ctx = NULL;
    unsigned char *got = NULL;
    size_t got_len;
    int i;
    OSSL_PARAM params[21];
    size_t params_n = 0;
    size_t params_n_allocstart = 0;
    const OSSL_PARAM *defined_params =
        EVP_MAC_CTX_settable_params(expected->mac);
    if (expected->alg == NULL)
        TEST_info("Trying the EVP_MAC %s test", EVP_MAC_name(expected->mac));
    else
        TEST_info("Trying the EVP_MAC %s test with %s",
                  EVP_MAC_name(expected->mac), expected->alg);
#ifdef OPENSSL_NO_DES
    if (expected->alg != NULL && strstr(expected->alg, "DES") != NULL) {
        t->err = NULL;
        goto err;
    }
#endif
    if (expected->alg != NULL)
        params[params_n++] =
            OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM,
                                             expected->alg,
                                             strlen(expected->alg) + 1);
    if (expected->key != NULL)
        params[params_n++] =
            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
                                              expected->key,
                                              expected->key_len);
    if (expected->custom != NULL)
        params[params_n++] =
            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_CUSTOM,
                                              expected->custom,
                                              expected->custom_len);
    if (expected->salt != NULL)
        params[params_n++] =
            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_SALT,
                                              expected->salt,
                                              expected->salt_len);
    if (expected->iv != NULL)
        params[params_n++] =
            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_IV,
                                              expected->iv,
                                              expected->iv_len);
    if (params_n + sk_OPENSSL_STRING_num(expected->controls)
        >= OSSL_NELEM(params)) {
        t->err = "MAC_TOO_MANY_PARAMETERS";
        goto err;
    }
    params_n_allocstart = params_n;
    for (i = 0; i < sk_OPENSSL_STRING_num(expected->controls); i++) {
        char *tmpkey, *tmpval;
        char *value = sk_OPENSSL_STRING_value(expected->controls, i);
        if (!TEST_ptr(tmpkey = OPENSSL_strdup(value))) {
            t->err = "MAC_PARAM_ERROR";
            goto err;
        }
        tmpval = strchr(tmpkey, ':');
        if (tmpval != NULL)
            *tmpval++ = '\0';
        if (!OSSL_PARAM_allocate_from_text(&params[params_n], defined_params,
                                           tmpkey, tmpval,
                                           strlen(tmpval))) {
            OPENSSL_free(tmpkey);
            t->err = "MAC_PARAM_ERROR";
            goto err;
        }
        params_n++;
        OPENSSL_free(tmpkey);
    }
    params[params_n] = OSSL_PARAM_construct_end();
    if ((ctx = EVP_MAC_CTX_new(expected->mac)) == NULL) {
        t->err = "MAC_CREATE_ERROR";
        goto err;
    }
    if (!EVP_MAC_CTX_set_params(ctx, params)) {
        t->err = "MAC_BAD_PARAMS";
        goto err;
    }
    if (!EVP_MAC_init(ctx)) {
        t->err = "MAC_INIT_ERROR";
        goto err;
    }
    if (!EVP_MAC_update(ctx, expected->input, expected->input_len)) {
        t->err = "MAC_UPDATE_ERROR";
        goto err;
    }
    if (!EVP_MAC_final(ctx, NULL, &got_len, 0)) {
        t->err = "MAC_FINAL_LENGTH_ERROR";
        goto err;
    }
    if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {
        t->err = "TEST_FAILURE";
        goto err;
    }
    if (!EVP_MAC_final(ctx, got, &got_len, got_len)
        || !memory_err_compare(t, "TEST_MAC_ERR",
                               expected->output, expected->output_len,
                               got, got_len)) {
        t->err = "TEST_MAC_ERR";
        goto err;
    }
    t->err = NULL;
 err:
    while (params_n-- > params_n_allocstart) {
        OPENSSL_free(params[params_n].data);
    }
    EVP_MAC_CTX_free(ctx);
    OPENSSL_free(got);
    return 1;
}
['static int mac_test_run_mac(EVP_TEST *t)\n{\n    MAC_DATA *expected = t->data;\n    EVP_MAC_CTX *ctx = NULL;\n    unsigned char *got = NULL;\n    size_t got_len;\n    int i;\n    OSSL_PARAM params[21];\n    size_t params_n = 0;\n    size_t params_n_allocstart = 0;\n    const OSSL_PARAM *defined_params =\n        EVP_MAC_CTX_settable_params(expected->mac);\n    if (expected->alg == NULL)\n        TEST_info("Trying the EVP_MAC %s test", EVP_MAC_name(expected->mac));\n    else\n        TEST_info("Trying the EVP_MAC %s test with %s",\n                  EVP_MAC_name(expected->mac), expected->alg);\n#ifdef OPENSSL_NO_DES\n    if (expected->alg != NULL && strstr(expected->alg, "DES") != NULL) {\n        t->err = NULL;\n        goto err;\n    }\n#endif\n    if (expected->alg != NULL)\n        params[params_n++] =\n            OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_ALGORITHM,\n                                             expected->alg,\n                                             strlen(expected->alg) + 1);\n    if (expected->key != NULL)\n        params[params_n++] =\n            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,\n                                              expected->key,\n                                              expected->key_len);\n    if (expected->custom != NULL)\n        params[params_n++] =\n            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_CUSTOM,\n                                              expected->custom,\n                                              expected->custom_len);\n    if (expected->salt != NULL)\n        params[params_n++] =\n            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_SALT,\n                                              expected->salt,\n                                              expected->salt_len);\n    if (expected->iv != NULL)\n        params[params_n++] =\n            OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_IV,\n                                              expected->iv,\n                                              expected->iv_len);\n    if (params_n + sk_OPENSSL_STRING_num(expected->controls)\n        >= OSSL_NELEM(params)) {\n        t->err = "MAC_TOO_MANY_PARAMETERS";\n        goto err;\n    }\n    params_n_allocstart = params_n;\n    for (i = 0; i < sk_OPENSSL_STRING_num(expected->controls); i++) {\n        char *tmpkey, *tmpval;\n        char *value = sk_OPENSSL_STRING_value(expected->controls, i);\n        if (!TEST_ptr(tmpkey = OPENSSL_strdup(value))) {\n            t->err = "MAC_PARAM_ERROR";\n            goto err;\n        }\n        tmpval = strchr(tmpkey, \':\');\n        if (tmpval != NULL)\n            *tmpval++ = \'\\0\';\n        if (!OSSL_PARAM_allocate_from_text(&params[params_n], defined_params,\n                                           tmpkey, tmpval,\n                                           strlen(tmpval))) {\n            OPENSSL_free(tmpkey);\n            t->err = "MAC_PARAM_ERROR";\n            goto err;\n        }\n        params_n++;\n        OPENSSL_free(tmpkey);\n    }\n    params[params_n] = OSSL_PARAM_construct_end();\n    if ((ctx = EVP_MAC_CTX_new(expected->mac)) == NULL) {\n        t->err = "MAC_CREATE_ERROR";\n        goto err;\n    }\n    if (!EVP_MAC_CTX_set_params(ctx, params)) {\n        t->err = "MAC_BAD_PARAMS";\n        goto err;\n    }\n    if (!EVP_MAC_init(ctx)) {\n        t->err = "MAC_INIT_ERROR";\n        goto err;\n    }\n    if (!EVP_MAC_update(ctx, expected->input, expected->input_len)) {\n        t->err = "MAC_UPDATE_ERROR";\n        goto err;\n    }\n    if (!EVP_MAC_final(ctx, NULL, &got_len, 0)) {\n        t->err = "MAC_FINAL_LENGTH_ERROR";\n        goto err;\n    }\n    if (!TEST_ptr(got = OPENSSL_malloc(got_len))) {\n        t->err = "TEST_FAILURE";\n        goto err;\n    }\n    if (!EVP_MAC_final(ctx, got, &got_len, got_len)\n        || !memory_err_compare(t, "TEST_MAC_ERR",\n                               expected->output, expected->output_len,\n                               got, got_len)) {\n        t->err = "TEST_MAC_ERR";\n        goto err;\n    }\n    t->err = NULL;\n err:\n    while (params_n-- > params_n_allocstart) {\n        OPENSSL_free(params[params_n].data);\n    }\n    EVP_MAC_CTX_free(ctx);\n    OPENSSL_free(got);\n    return 1;\n}']