test/ct_test.c:355: error: BUFFER_OVERRUN_L3
  Offset: [2, +oo] Size: [1, +oo] by call to `execute_cert_test`.
Showing all 13 steps of the trace


test/ct_test.c:355:5: Call
353.       fixture.issuer_file = "subinterCA.pem";
354.       fixture.expected_sct_count = 0;
355.       EXECUTE_CT_TEST();
           ^
356.   }
357.   

test/ct_test.c:236:1: Parameter `fixture.tls_sct_list_len`
  234.   }
  235.   
  236. > static int execute_cert_test(CT_TEST_FIXTURE fixture)
  237.   {
  238.       int success = 0;

test/ct_test.c:329:14: Call
  327.   
  328.           tls_sct_list_len = i2o_SCT_LIST(scts, &tls_sct_list);
  329.           if (!TEST_mem_eq(fixture.tls_sct_list, fixture.tls_sct_list_len,
                      ^
  330.                            tls_sct_list, tls_sct_list_len))
  331.               goto end;

test/testutil/tests.c:310:1: Parameter `n1`
    308.   }
    309.   
    310. > int test_mem_eq(const char *file, int line, const char *st1, const char *st2,
    311.                   const void *s1, size_t n1, const void *s2, size_t n2)
    312.   {

test/testutil/tests.c:318:20: Call
    316.           return 1;
    317.       if (n1 != n2 || s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {
    318.           char *m1 = print_mem_maybe_null(s1, n1, b1);
                              ^
    319.           char *m2 = print_mem_maybe_null(s2, n2, b2);
    320.   

test/testutil/tests.c:276:1: <Offset trace>
274.    * freed by the caller.
275.    */
276. > static char *print_mem_maybe_null(const void *s, size_t n,
277.                                     char outbuf[MEM_BUFFER_SIZE])
278.   {

test/testutil/tests.c:276:1: Parameter `n`
      274.    * freed by the caller.
      275.    */
      276. > static char *print_mem_maybe_null(const void *s, size_t n,
      277.                                     char outbuf[MEM_BUFFER_SIZE])
      278.   {

test/testutil/tests.c:301:13: Assignment
      299.       }
      300.       if (pad) {
      301.           out[i++] = '.';
                         ^
      302.           out[i++] = '.';
      303.           out[i++] = '.';

test/testutil/tests.c:302:13: Assignment
      300.       if (pad) {
      301.           out[i++] = '.';
      302.           out[i++] = '.';
                         ^
      303.           out[i++] = '.';
      304.       }

test/testutil/tests.c:276:1: <Length trace>
274.    * freed by the caller.
275.    */
276. > static char *print_mem_maybe_null(const void *s, size_t n,
277.                                     char outbuf[MEM_BUFFER_SIZE])
278.   {

test/testutil/tests.c:276:1: Parameter `*outbuf`
      274.    * freed by the caller.
      275.    */
      276. > static char *print_mem_maybe_null(const void *s, size_t n,
      277.                                     char outbuf[MEM_BUFFER_SIZE])
      278.   {

test/testutil/tests.c:281:5: Assignment
      279.       size_t i;
      280.       const unsigned char *p = (const unsigned char *)s;
      281.       char *out = outbuf;
                 ^
      282.       int pad = 2 * n >= MEM_BUFFER_SIZE;
      283.   

test/testutil/tests.c:303:9: Array access: Offset: [2, +oo] Size: [1, +oo] by call to `execute_cert_test` 
      301.           out[i++] = '.';
      302.           out[i++] = '.';
      303.           out[i++] = '.';
                     ^
      304.       }
      305.       out[i] = '\0';

static char *print_mem_maybe_null(const void *s, size_t n,
                                  char outbuf[MEM_BUFFER_SIZE])
{
    size_t i;
    const unsigned char *p = (const unsigned char *)s;
    char *out = outbuf;
    int pad = 2 * n >= MEM_BUFFER_SIZE;
    if (s == NULL)
        return strcpy(outbuf, "(NULL)");
    if (pad) {
        if ((out = OPENSSL_malloc(2 * n + 1)) == NULL) {
            out = outbuf;
            n = (MEM_BUFFER_SIZE - 4) / 2;
        } else {
            pad = 0;
        }
    }
    for (i = 0; i < 2 * n; ) {
        const unsigned char c = *p++;
        out[i++] = "0123456789abcdef"[c >> 4];
        out[i++] = "0123456789abcdef"[c & 15];
    }
    if (pad) {
        out[i++] = '.';
        out[i++] = '.';
        out[i++] = '.';
    }
    out[i] = '\0';
    return out;
}
['static int test_no_scts_in_certificate()\n{\n    SETUP_CT_TEST_FIXTURE();\n    fixture.certs_dir = certs_dir;\n    fixture.certificate_file = "leaf.pem";\n    fixture.issuer_file = "subinterCA.pem";\n    fixture.expected_sct_count = 0;\n    EXECUTE_CT_TEST();\n}', "static int execute_cert_test(CT_TEST_FIXTURE fixture)\n{\n    int success = 0;\n    X509 *cert = NULL, *issuer = NULL;\n    STACK_OF(SCT) *scts = NULL;\n    SCT *sct = NULL;\n    char expected_sct_text[CT_TEST_MAX_FILE_SIZE];\n    int sct_text_len = 0;\n    unsigned char *tls_sct_list = NULL;\n    size_t tls_sct_list_len = 0;\n    CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new();\n    if (fixture.sct_text_file != NULL) {\n        sct_text_len = read_text_file(fixture.sct_dir, fixture.sct_text_file,\n                                      expected_sct_text,\n                                      CT_TEST_MAX_FILE_SIZE - 1);\n        if (!TEST_int_ge(sct_text_len, 0))\n            goto end;\n        expected_sct_text[sct_text_len] = '\\0';\n    }\n    CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(\n            ct_policy_ctx, fixture.ctlog_store);\n    CT_POLICY_EVAL_CTX_set_time(ct_policy_ctx, fixture.epoch_time_in_ms);\n    if (fixture.certificate_file != NULL) {\n        int sct_extension_index;\n        X509_EXTENSION *sct_extension = NULL;\n        if (!TEST_ptr(cert = load_pem_cert(fixture.certs_dir,\n                                           fixture.certificate_file)))\n            goto end;\n        CT_POLICY_EVAL_CTX_set1_cert(ct_policy_ctx, cert);\n        if (fixture.issuer_file != NULL) {\n            if (!TEST_ptr(issuer = load_pem_cert(fixture.certs_dir,\n                                                 fixture.issuer_file)))\n                goto end;\n            CT_POLICY_EVAL_CTX_set1_issuer(ct_policy_ctx, issuer);\n        }\n        sct_extension_index =\n                X509_get_ext_by_NID(cert, NID_ct_precert_scts, -1);\n        sct_extension = X509_get_ext(cert, sct_extension_index);\n        if (fixture.expected_sct_count > 0) {\n            if (!TEST_ptr(sct_extension))\n                goto end;\n            if (fixture.sct_text_file\n                && !compare_extension_printout(sct_extension,\n                                               expected_sct_text))\n                    goto end;\n            if (fixture.test_validity) {\n                int i;\n                scts = X509V3_EXT_d2i(sct_extension);\n                for (i = 0; i < sk_SCT_num(scts); ++i) {\n                    SCT *sct_i = sk_SCT_value(scts, i);\n                    if (!TEST_true(SCT_set_source(sct_i,\n                                                  SCT_SOURCE_X509V3_EXTENSION)))\n                        goto end;\n                }\n                if (!assert_validity(fixture, scts, ct_policy_ctx))\n                    goto end;\n            }\n        } else if (!TEST_ptr_null(sct_extension)) {\n            goto end;\n        }\n    }\n    if (fixture.tls_sct_list != NULL) {\n        const unsigned char *p = fixture.tls_sct_list;\n        if (!TEST_ptr(o2i_SCT_LIST(&scts, &p, fixture.tls_sct_list_len)))\n            goto end;\n        if (fixture.test_validity && cert != NULL) {\n            if (!assert_validity(fixture, scts, ct_policy_ctx))\n                goto end;\n        }\n        if (fixture.sct_text_file\n            && !compare_sct_list_printout(scts, expected_sct_text)) {\n                goto end;\n        }\n        tls_sct_list_len = i2o_SCT_LIST(scts, &tls_sct_list);\n        if (!TEST_mem_eq(fixture.tls_sct_list, fixture.tls_sct_list_len,\n                         tls_sct_list, tls_sct_list_len))\n            goto end;\n    }\n    success = 1;\nend:\n    X509_free(cert);\n    X509_free(issuer);\n    SCT_LIST_free(scts);\n    SCT_free(sct);\n    CT_POLICY_EVAL_CTX_free(ct_policy_ctx);\n    OPENSSL_free(tls_sct_list);\n    return success;\n}", 'int test_mem_eq(const char *file, int line, const char *st1, const char *st2,\n                const void *s1, size_t n1, const void *s2, size_t n2)\n{\n    char b1[MEM_BUFFER_SIZE], b2[MEM_BUFFER_SIZE];\n    if (s1 == NULL && s2 == NULL)\n        return 1;\n    if (n1 != n2 || s1 == NULL || s2 == NULL || memcmp(s1, s2, n1) != 0) {\n        char *m1 = print_mem_maybe_null(s1, n1, b1);\n        char *m2 = print_mem_maybe_null(s2, n2, b2);\n        test_fail_message(NULL, file, line, "memory",\n                          "%s %s [%zu] == %s %s [%zu]",\n                          st1, m1, n1, st2, m2, n2);\n        if (m1 != b1)\n            OPENSSL_free(m1);\n        if (m2 != b2)\n            OPENSSL_free(m2);\n        return 0;\n    }\n    return 1;\n}', 'static char *print_mem_maybe_null(const void *s, size_t n,\n                                  char outbuf[MEM_BUFFER_SIZE])\n{\n    size_t i;\n    const unsigned char *p = (const unsigned char *)s;\n    char *out = outbuf;\n    int pad = 2 * n >= MEM_BUFFER_SIZE;\n    if (s == NULL)\n        return strcpy(outbuf, "(NULL)");\n    if (pad) {\n        if ((out = OPENSSL_malloc(2 * n + 1)) == NULL) {\n            out = outbuf;\n            n = (MEM_BUFFER_SIZE - 4) / 2;\n        } else {\n            pad = 0;\n        }\n    }\n    for (i = 0; i < 2 * n; ) {\n        const unsigned char c = *p++;\n        out[i++] = "0123456789abcdef"[c >> 4];\n        out[i++] = "0123456789abcdef"[c & 15];\n    }\n    if (pad) {\n        out[i++] = \'.\';\n        out[i++] = \'.\';\n        out[i++] = \'.\';\n    }\n    out[i] = \'\\0\';\n    return out;\n}']