test/x509aux.c:32: error: BUFFER_OVERRUN_L2
  Offset: [max(0, `num`), 399] Size: 100 by call to `test_get_argument`.
Showing all 7 steps of the trace


test/x509aux.c:22:1: Parameter `num`
20.   #include "testutil.h"
21.   
22. > static int test_certs(int num)
23.   {
24.       int c;

test/x509aux.c:32:28: Call
30.       typedef int (*i2d_X509_t)(const X509 *, unsigned char **);
31.       int err = 0;
32.       BIO *fp = BIO_new_file(test_get_argument(num), "r");
                                 ^
33.       X509 *reuse = NULL;
34.   

test/testutil/options.c:24:1: <Offset trace>
22.   }
23.   
24. > char *test_get_argument(size_t n)
25.   {
26.       char **argv = opt_rest();

test/testutil/options.c:24:1: Parameter `n`
  22.   }
  23.   
  24. > char *test_get_argument(size_t n)
  25.   {
  26.       char **argv = opt_rest();

test/testutil/options.c:16:1: <Length trace>
14.   
15.   
16. > static int used[100] = { 0 };
17.   
18.   

test/testutil/options.c:16:1: Array declaration
  14.   
  15.   
  16. > static int used[100] = { 0 };
  17.   
  18.   

test/testutil/options.c:31:5: Array access: Offset: [max(0, num), 399] Size: 100 by call to `test_get_argument` 
  29.       if ((int)n >= opt_num_rest() || argv == NULL)
  30.           return NULL;
  31.       used[n] = 1;
            ^
  32.       return argv[n];
  33.   }

char *test_get_argument(size_t n)
{
    char **argv = opt_rest();
    OPENSSL_assert(n < sizeof(used));
    if ((int)n >= opt_num_rest() || argv == NULL)
        return NULL;
    used[n] = 1;
    return argv[n];
}
['static int test_certs(int num)\n{\n    int c;\n    char *name = 0;\n    char *header = 0;\n    unsigned char *data = 0;\n    long len;\n    typedef X509 *(*d2i_X509_t)(X509 **, const unsigned char **, long);\n    typedef int (*i2d_X509_t)(const X509 *, unsigned char **);\n    int err = 0;\n    BIO *fp = BIO_new_file(test_get_argument(num), "r");\n    X509 *reuse = NULL;\n    if (!TEST_ptr(fp))\n        return 0;\n    for (c = 0; !err && PEM_read_bio(fp, &name, &header, &data, &len); ++c) {\n        const int trusted = (strcmp(name, PEM_STRING_X509_TRUSTED) == 0);\n        d2i_X509_t d2i = trusted ? d2i_X509_AUX : d2i_X509;\n        i2d_X509_t i2d = trusted ? i2d_X509_AUX : i2d_X509;\n        X509 *cert = NULL;\n        const unsigned char *p = data;\n        unsigned char *buf = NULL;\n        unsigned char *bufp;\n        long enclen;\n        if (!trusted\n            && strcmp(name, PEM_STRING_X509) != 0\n            && strcmp(name, PEM_STRING_X509_OLD) != 0) {\n            TEST_error("unexpected PEM object: %s", name);\n            err = 1;\n            goto next;\n        }\n        cert = d2i(NULL, &p, len);\n        if (cert == NULL || (p - data) != len) {\n            TEST_error("error parsing input %s", name);\n            err = 1;\n            goto next;\n        }\n        enclen = i2d(cert, NULL);\n        if (len != enclen) {\n            TEST_error("encoded length %ld of %s != input length %ld",\n                       enclen, name, len);\n            err = 1;\n            goto next;\n        }\n        if ((buf = bufp = OPENSSL_malloc(len)) == NULL) {\n            TEST_perror("malloc");\n            err = 1;\n            goto next;\n        }\n        enclen = i2d(cert, &bufp);\n        if (len != enclen) {\n            TEST_error("encoded length %ld of %s != input length %ld",\n                       enclen, name, len);\n            err = 1;\n            goto next;\n        }\n        enclen = (long) (bufp - buf);\n        if (enclen != len) {\n            TEST_error("unexpected buffer position after encoding %s", name);\n            err = 1;\n            goto next;\n        }\n        if (memcmp(buf, data, len) != 0) {\n            TEST_error("encoded content of %s does not match input", name);\n            err = 1;\n            goto next;\n        }\n        p = buf;\n        reuse = d2i(&reuse, &p, enclen);\n        if (reuse == NULL || X509_cmp (reuse, cert)) {\n            TEST_error("X509_cmp does not work with %s", name);\n            err = 1;\n            goto next;\n        }\n        OPENSSL_free(buf);\n        buf = NULL;\n        enclen = i2d(cert, &buf);\n        if (len != enclen) {\n            TEST_error("encoded length %ld of %s != input length %ld",\n                       enclen, name, len);\n            err = 1;\n            goto next;\n        }\n        if (memcmp(buf, data, len) != 0) {\n            TEST_error("encoded content of %s does not match input", name);\n            err = 1;\n            goto next;\n        }\n        if (trusted) {\n            OPENSSL_free(buf);\n            buf = NULL;\n            enclen = i2d(cert, &buf);\n            if (enclen > len) {\n                TEST_error("encoded length %ld of %s > input length %ld",\n                           enclen, name, len);\n                err = 1;\n                goto next;\n            }\n            if (memcmp(buf, data, enclen) != 0) {\n                TEST_error("encoded cert content does not match input");\n                err = 1;\n                goto next;\n            }\n        }\n    next:\n        X509_free(cert);\n        OPENSSL_free(buf);\n        OPENSSL_free(name);\n        OPENSSL_free(header);\n        OPENSSL_free(data);\n    }\n    BIO_free(fp);\n    X509_free(reuse);\n    if (ERR_GET_REASON(ERR_peek_last_error()) == PEM_R_NO_START_LINE) {\n        if (c > 0) {\n            ERR_clear_error();\n            return 1;\n        }\n    }\n    return 0;\n}', 'char *test_get_argument(size_t n)\n{\n    char **argv = opt_rest();\n    OPENSSL_assert(n < sizeof(used));\n    if ((int)n >= opt_num_rest() || argv == NULL)\n        return NULL;\n    used[n] = 1;\n    return argv[n];\n}']