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


apps/mac.c:113:14: <LHS trace>
111.           int ok = 1;
112.   
113.           for (params_n = 0; params_n < (size_t)sk_OPENSSL_STRING_num(opts);
                    ^
114.                params_n++) {
115.               char *opt = sk_OPENSSL_STRING_value(opts, (int)params_n);

apps/mac.c:113:14: Assignment
111.           int ok = 1;
112.   
113.           for (params_n = 0; params_n < (size_t)sk_OPENSSL_STRING_num(opts);
                    ^
114.                params_n++) {
115.               char *opt = sk_OPENSSL_STRING_value(opts, (int)params_n);

apps/mac.c:139:16: Binary operation: ([0, +oo] - 1):unsigned64
137.               }
138.           }
139.           for (; params_n-- > 0;) {
                      ^
140.               OPENSSL_free(params[params_n].data);
141.           }

int mac_main(int argc, char **argv)
{
    int ret = 1;
    char *prog;
    EVP_MAC *mac = NULL;
    OPTION_CHOICE o;
    EVP_MAC_CTX *ctx = NULL;
    STACK_OF(OPENSSL_STRING) *opts = NULL;
    unsigned char *buf = NULL;
    size_t len;
    int i;
    BIO *in = NULL, *out = NULL;
    const char *outfile = NULL;
    const char *infile = NULL;
    int out_bin = 0;
    int inform = FORMAT_BINARY;
    prog = opt_init(argc, argv, mac_options);
    buf = app_malloc(BUFSIZE, "I/O buffer");
    while ((o = opt_next()) != OPT_EOF) {
        switch (o) {
        default:
opthelp:
            BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
            goto err;
        case OPT_HELP:
            opt_help(mac_options);
            ret = 0;
            goto err;
        case OPT_BIN:
            out_bin = 1;
            break;
        case OPT_IN:
            infile = opt_arg();
            break;
        case OPT_OUT:
            outfile = opt_arg();
            break;
        case OPT_MACOPT:
            if (opts == NULL)
                opts = sk_OPENSSL_STRING_new_null();
            if (opts == NULL || !sk_OPENSSL_STRING_push(opts, opt_arg()))
                goto opthelp;
            break;
        }
    }
    argc = opt_num_rest();
    argv = opt_rest();
    if (argc != 1) {
        BIO_printf(bio_err, "Invalid number of extra arguments\n");
        goto opthelp;
    }
    mac = EVP_MAC_fetch(NULL, argv[0], NULL);
    if (mac == NULL) {
        BIO_printf(bio_err, "Invalid MAC name %s\n", argv[0]);
        goto opthelp;
    }
    ctx = EVP_MAC_CTX_new(mac);
    if (ctx == NULL)
        goto err;
    if (opts != NULL) {
        OSSL_PARAM *params =
            OPENSSL_zalloc(sizeof(OSSL_PARAM)
                           * (sk_OPENSSL_STRING_num(opts) + 1));
        const OSSL_PARAM *paramdefs = EVP_MAC_CTX_settable_params(mac);
        size_t params_n;
        int ok = 1;
        for (params_n = 0; params_n < (size_t)sk_OPENSSL_STRING_num(opts);
             params_n++) {
            char *opt = sk_OPENSSL_STRING_value(opts, (int)params_n);
            char *stmp, *vtmp = NULL;
            if ((stmp = OPENSSL_strdup(opt)) == NULL
                || (vtmp = strchr(stmp, ':')) == NULL
                || (*vtmp++ = 0)
                || !OSSL_PARAM_allocate_from_text(&params[params_n], paramdefs,
                                                  stmp, vtmp, strlen(vtmp))) {
                BIO_printf(bio_err, "MAC parameter error '%s'\n", opt);
                ERR_print_errors(bio_err);
                ok = 0;
            }
            OPENSSL_free(stmp);
            if (!ok)
                break;
        }
        if (ok) {
            params[params_n] = OSSL_PARAM_construct_end();
            if (!EVP_MAC_CTX_set_params(ctx, params)) {
                BIO_printf(bio_err, "MAC parameter error\n");
                ERR_print_errors(bio_err);
                goto err;
            }
        }
        for (; params_n-- > 0;) {
            OPENSSL_free(params[params_n].data);
        }
        OPENSSL_free(params);
        if (!ok)
            goto err;
    }
    if (infile == NULL || strcmp(infile, "-") == 0)
        inform = FORMAT_TEXT;
    in = bio_open_default(infile, 'r', inform);
    if (in == NULL)
        goto err;
    out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT);
    if (out == NULL)
        goto err;
    if (!EVP_MAC_init(ctx)) {
        BIO_printf(bio_err, "EVP_MAC_Init failed\n");
        goto err;
    }
    for (;;) {
        i = BIO_read(in, (char *)buf, BUFSIZE);
        if (i < 0) {
            BIO_printf(bio_err, "Read Error in '%s'\n", infile);
            goto err;
        }
        if (i == 0)
            break;
        if (!EVP_MAC_update(ctx, buf, i)) {
            BIO_printf(bio_err, "EVP_MAC_update failed\n");
            goto err;
        }
    }
    if (!EVP_MAC_final(ctx, NULL, &len, 0)) {
        BIO_printf(bio_err, "EVP_MAC_final failed\n");
        goto err;
    }
    if (len > BUFSIZE) {
        BIO_printf(bio_err, "output len is too large\n");
        goto err;
    }
    if (!EVP_MAC_final(ctx, buf, &len, BUFSIZE)) {
        BIO_printf(bio_err, "EVP_MAC_final failed\n");
        goto err;
    }
    if (out_bin) {
        BIO_write(out, buf, len);
    } else {
        if (outfile == NULL)
            BIO_printf(out,"\n");
        for (i = 0; i < (int)len; ++i)
            BIO_printf(out, "%02X", buf[i]);
        if (outfile == NULL)
            BIO_printf(out,"\n");
    }
    ret = 0;
err:
    if (ret != 0)
        ERR_print_errors(bio_err);
    OPENSSL_clear_free(buf, BUFSIZE);
    sk_OPENSSL_STRING_free(opts);
    BIO_free(in);
    BIO_free(out);
    EVP_MAC_CTX_free(ctx);
    EVP_MAC_free(mac);
    return ret;
}
['int mac_main(int argc, char **argv)\n{\n    int ret = 1;\n    char *prog;\n    EVP_MAC *mac = NULL;\n    OPTION_CHOICE o;\n    EVP_MAC_CTX *ctx = NULL;\n    STACK_OF(OPENSSL_STRING) *opts = NULL;\n    unsigned char *buf = NULL;\n    size_t len;\n    int i;\n    BIO *in = NULL, *out = NULL;\n    const char *outfile = NULL;\n    const char *infile = NULL;\n    int out_bin = 0;\n    int inform = FORMAT_BINARY;\n    prog = opt_init(argc, argv, mac_options);\n    buf = app_malloc(BUFSIZE, "I/O buffer");\n    while ((o = opt_next()) != OPT_EOF) {\n        switch (o) {\n        default:\nopthelp:\n            BIO_printf(bio_err, "%s: Use -help for summary.\\n", prog);\n            goto err;\n        case OPT_HELP:\n            opt_help(mac_options);\n            ret = 0;\n            goto err;\n        case OPT_BIN:\n            out_bin = 1;\n            break;\n        case OPT_IN:\n            infile = opt_arg();\n            break;\n        case OPT_OUT:\n            outfile = opt_arg();\n            break;\n        case OPT_MACOPT:\n            if (opts == NULL)\n                opts = sk_OPENSSL_STRING_new_null();\n            if (opts == NULL || !sk_OPENSSL_STRING_push(opts, opt_arg()))\n                goto opthelp;\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    argv = opt_rest();\n    if (argc != 1) {\n        BIO_printf(bio_err, "Invalid number of extra arguments\\n");\n        goto opthelp;\n    }\n    mac = EVP_MAC_fetch(NULL, argv[0], NULL);\n    if (mac == NULL) {\n        BIO_printf(bio_err, "Invalid MAC name %s\\n", argv[0]);\n        goto opthelp;\n    }\n    ctx = EVP_MAC_CTX_new(mac);\n    if (ctx == NULL)\n        goto err;\n    if (opts != NULL) {\n        OSSL_PARAM *params =\n            OPENSSL_zalloc(sizeof(OSSL_PARAM)\n                           * (sk_OPENSSL_STRING_num(opts) + 1));\n        const OSSL_PARAM *paramdefs = EVP_MAC_CTX_settable_params(mac);\n        size_t params_n;\n        int ok = 1;\n        for (params_n = 0; params_n < (size_t)sk_OPENSSL_STRING_num(opts);\n             params_n++) {\n            char *opt = sk_OPENSSL_STRING_value(opts, (int)params_n);\n            char *stmp, *vtmp = NULL;\n            if ((stmp = OPENSSL_strdup(opt)) == NULL\n                || (vtmp = strchr(stmp, \':\')) == NULL\n                || (*vtmp++ = 0)\n                || !OSSL_PARAM_allocate_from_text(&params[params_n], paramdefs,\n                                                  stmp, vtmp, strlen(vtmp))) {\n                BIO_printf(bio_err, "MAC parameter error \'%s\'\\n", opt);\n                ERR_print_errors(bio_err);\n                ok = 0;\n            }\n            OPENSSL_free(stmp);\n            if (!ok)\n                break;\n        }\n        if (ok) {\n            params[params_n] = OSSL_PARAM_construct_end();\n            if (!EVP_MAC_CTX_set_params(ctx, params)) {\n                BIO_printf(bio_err, "MAC parameter error\\n");\n                ERR_print_errors(bio_err);\n                goto err;\n            }\n        }\n        for (; params_n-- > 0;) {\n            OPENSSL_free(params[params_n].data);\n        }\n        OPENSSL_free(params);\n        if (!ok)\n            goto err;\n    }\n    if (infile == NULL || strcmp(infile, "-") == 0)\n        inform = FORMAT_TEXT;\n    in = bio_open_default(infile, \'r\', inform);\n    if (in == NULL)\n        goto err;\n    out = bio_open_default(outfile, \'w\', out_bin ? FORMAT_BINARY : FORMAT_TEXT);\n    if (out == NULL)\n        goto err;\n    if (!EVP_MAC_init(ctx)) {\n        BIO_printf(bio_err, "EVP_MAC_Init failed\\n");\n        goto err;\n    }\n    for (;;) {\n        i = BIO_read(in, (char *)buf, BUFSIZE);\n        if (i < 0) {\n            BIO_printf(bio_err, "Read Error in \'%s\'\\n", infile);\n            goto err;\n        }\n        if (i == 0)\n            break;\n        if (!EVP_MAC_update(ctx, buf, i)) {\n            BIO_printf(bio_err, "EVP_MAC_update failed\\n");\n            goto err;\n        }\n    }\n    if (!EVP_MAC_final(ctx, NULL, &len, 0)) {\n        BIO_printf(bio_err, "EVP_MAC_final failed\\n");\n        goto err;\n    }\n    if (len > BUFSIZE) {\n        BIO_printf(bio_err, "output len is too large\\n");\n        goto err;\n    }\n    if (!EVP_MAC_final(ctx, buf, &len, BUFSIZE)) {\n        BIO_printf(bio_err, "EVP_MAC_final failed\\n");\n        goto err;\n    }\n    if (out_bin) {\n        BIO_write(out, buf, len);\n    } else {\n        if (outfile == NULL)\n            BIO_printf(out,"\\n");\n        for (i = 0; i < (int)len; ++i)\n            BIO_printf(out, "%02X", buf[i]);\n        if (outfile == NULL)\n            BIO_printf(out,"\\n");\n    }\n    ret = 0;\nerr:\n    if (ret != 0)\n        ERR_print_errors(bio_err);\n    OPENSSL_clear_free(buf, BUFSIZE);\n    sk_OPENSSL_STRING_free(opts);\n    BIO_free(in);\n    BIO_free(out);\n    EVP_MAC_CTX_free(ctx);\n    EVP_MAC_free(mac);\n    return ret;\n}']