test/tls13secretstest.c:344: error: BUFFER_OVERRUN_L3
  Offset: [2, +oo] Size: [1, +oo] by call to `test_mem_eq`.
Showing all 15 steps of the trace


test/tls13secretstest.c:337:10: Call
335.       full_hash = 1;
336.   
337.       if (!TEST_true(tls13_generate_master_secret(s, out_master_secret,
                ^
338.                                                   s->handshake_secret, hashsize,
339.                                                   &master_secret_length))) {

ssl/tls13_enc.c:206:20: Call
  204.       const EVP_MD *md = ssl_handshake_md(s);
  205.   
  206.       *secret_size = EVP_MD_size(md);
                            ^
  207.       return tls13_generate_secret(s, md, prev, NULL, 0, out);
  208.   }

crypto/evp/evp_lib.c:305:9: Assignment
    303.       if (!md) {
    304.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
    305.           return -1;
                   ^
    306.       }
    307.       return md->md_size;

ssl/tls13_enc.c:206:5: Assignment
  204.       const EVP_MD *md = ssl_handshake_md(s);
  205.   
  206.       *secret_size = EVP_MD_size(md);
             ^
  207.       return tls13_generate_secret(s, md, prev, NULL, 0, out);
  208.   }

test/tls13secretstest.c:344:10: Call
342.       }
343.   
344.       if (!TEST_mem_eq(out_master_secret, master_secret_length,
                ^
345.                        master_secret, sizeof(master_secret))) {
346.           TEST_info("Master secret does not match");

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 `test_mem_eq` 
    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_handshake_secrets(void)\n{\n    SSL_CTX *ctx = NULL;\n    SSL *s = NULL;\n    int ret = 0;\n    size_t hashsize;\n    unsigned char out_master_secret[EVP_MAX_MD_SIZE];\n    size_t master_secret_length;\n    ctx = SSL_CTX_new(TLS_method());\n    if (!TEST_ptr(ctx))\n        goto err;\n    s = SSL_new(ctx);\n    if (!TEST_ptr(s ))\n        goto err;\n    s->session = SSL_SESSION_new();\n    if (!TEST_ptr(s->session))\n        goto err;\n    if (!TEST_true(tls13_generate_secret(s, ssl_handshake_md(s), NULL, NULL, 0,\n                                         (unsigned char *)&s->early_secret))) {\n        TEST_info("Early secret generation failed");\n        goto err;\n    }\n    if (!TEST_mem_eq(s->early_secret, sizeof(early_secret),\n                     early_secret, sizeof(early_secret))) {\n        TEST_info("Early secret does not match");\n        goto err;\n    }\n    if (!TEST_true(tls13_generate_handshake_secret(s, ecdhe_secret,\n                                                   sizeof(ecdhe_secret)))) {\n        TEST_info("Hanshake secret generation failed");\n        goto err;\n    }\n    if (!TEST_mem_eq(s->handshake_secret, sizeof(handshake_secret),\n                     handshake_secret, sizeof(handshake_secret)))\n        goto err;\n    hashsize = EVP_MD_size(ssl_handshake_md(s));\n    if (!TEST_size_t_eq(sizeof(client_hts), hashsize))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(client_hts_key), KEYLEN))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(client_hts_iv), IVLEN))\n        goto err;\n    if (!TEST_true(test_secret(s, s->handshake_secret,\n                               (unsigned char *)client_hts_label,\n                               strlen(client_hts_label), client_hts,\n                               client_hts_key, client_hts_iv))) {\n        TEST_info("Client handshake secret test failed");\n        goto err;\n    }\n    if (!TEST_size_t_eq(sizeof(server_hts), hashsize))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(server_hts_key), KEYLEN))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(server_hts_iv), IVLEN))\n        goto err;\n    if (!TEST_true(test_secret(s, s->handshake_secret,\n                               (unsigned char *)server_hts_label,\n                               strlen(server_hts_label), server_hts,\n                               server_hts_key, server_hts_iv))) {\n        TEST_info("Server handshake secret test failed");\n        goto err;\n    }\n    full_hash = 1;\n    if (!TEST_true(tls13_generate_master_secret(s, out_master_secret,\n                                                s->handshake_secret, hashsize,\n                                                &master_secret_length))) {\n        TEST_info("Master secret generation failed");\n        goto err;\n    }\n    if (!TEST_mem_eq(out_master_secret, master_secret_length,\n                     master_secret, sizeof(master_secret))) {\n        TEST_info("Master secret does not match");\n        goto err;\n    }\n    if (!TEST_size_t_eq(sizeof(client_ats), hashsize))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(client_ats_key), KEYLEN))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(client_ats_iv), IVLEN))\n        goto err;\n    if (!TEST_true(test_secret(s, out_master_secret,\n                               (unsigned char *)client_ats_label,\n                               strlen(client_ats_label), client_ats,\n                               client_ats_key, client_ats_iv))) {\n        TEST_info("Client application data secret test failed");\n        goto err;\n    }\n    if (!TEST_size_t_eq(sizeof(server_ats), hashsize))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(server_ats_key), KEYLEN))\n        goto err;\n    if (!TEST_size_t_eq(sizeof(server_ats_iv), IVLEN))\n        goto err;\n    if (!TEST_true(test_secret(s, out_master_secret,\n                               (unsigned char *)server_ats_label,\n                               strlen(server_ats_label), server_ats,\n                               server_ats_key, server_ats_iv))) {\n        TEST_info("Server application data secret test failed");\n        goto err;\n    }\n    ret = 1;\n err:\n    SSL_free(s);\n    SSL_CTX_free(ctx);\n    return ret;\n}', 'int tls13_generate_master_secret(SSL *s, unsigned char *out,\n                                 unsigned char *prev, size_t prevlen,\n                                 size_t *secret_size)\n{\n    const EVP_MD *md = ssl_handshake_md(s);\n    *secret_size = EVP_MD_size(md);\n    return tls13_generate_secret(s, md, prev, NULL, 0, out);\n}', 'int EVP_MD_size(const EVP_MD *md)\n{\n    if (!md) {\n        EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);\n        return -1;\n    }\n    return md->md_size;\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}']