test/ct_test.c:456: error: BUFFER_OVERRUN_L1
  Offset: [-oo, -1] Size: 1 by call to `SCT_new_from_base64`.
Showing all 10 steps of the trace


test/ct_test.c:444:1: Array declaration
442.   }
443.   
444. > static int test_encode_tls_sct(void)
445.   {
446.       const char log_id[] = "3xwuwRUAlFJHqWFoMl3cXHlZ6PfG04j8AC4LvT9012Q=";

test/ct_test.c:456:10: Call
454.   
455.       fixture.sct_list = sk_SCT_new_null();
456.       if (!TEST_ptr(sct = SCT_new_from_base64(SCT_VERSION_V1, log_id,
                ^
457.                                               CT_LOG_ENTRY_TYPE_X509, timestamp,
458.                                               extensions, signature)))

crypto/ct/ct_b64.c:63:1: Parameter `*extensions_base64`
  61.   }
  62.   
  63. > SCT *SCT_new_from_base64(unsigned char version, const char *logid_base64,
  64.                            ct_log_entry_type_t entry_type, uint64_t timestamp,
  65.                            const char *extensions_base64,

crypto/ct/ct_b64.c:96:14: Call
  94.       dec = NULL;
  95.   
  96.       declen = ct_base64_decode(extensions_base64, &dec);
                     ^
  97.       if (declen < 0) {
  98.           CTerr(CT_F_SCT_NEW_FROM_BASE64, X509_R_BASE64_DECODE_ERROR);

crypto/ct/ct_b64.c:24:1: <Offset trace>
22.    * the caller. Do not provide a pre-allocated string in |out|.
23.    */
24. > static int ct_base64_decode(const char *in, unsigned char **out)
25.   {
26.       size_t inlen = strlen(in);

crypto/ct/ct_b64.c:24:1: Parameter `in->strlen`
    22.    * the caller. Do not provide a pre-allocated string in |out|.
    23.    */
    24. > static int ct_base64_decode(const char *in, unsigned char **out)
    25.   {
    26.       size_t inlen = strlen(in);

crypto/ct/ct_b64.c:26:5: Assignment
    24.   static int ct_base64_decode(const char *in, unsigned char **out)
    25.   {
    26.       size_t inlen = strlen(in);
              ^
    27.       int outlen, i;
    28.       unsigned char *outbuf = NULL;

crypto/ct/ct_b64.c:24:1: <Length trace>
22.    * the caller. Do not provide a pre-allocated string in |out|.
23.    */
24. > static int ct_base64_decode(const char *in, unsigned char **out)
25.   {
26.       size_t inlen = strlen(in);

crypto/ct/ct_b64.c:24:1: Parameter `*in`
    22.    * the caller. Do not provide a pre-allocated string in |out|.
    23.    */
    24. > static int ct_base64_decode(const char *in, unsigned char **out)
    25.   {
    26.       size_t inlen = strlen(in);

crypto/ct/ct_b64.c:50:12: Array access: Offset: [-oo, -1] Size: 1 by call to `SCT_new_from_base64` 
    48.       /* Subtract padding bytes from |outlen|.  Any more than 2 is malformed. */
    49.       i = 0;
    50.       while (in[--inlen] == '=') {
                     ^
    51.           --outlen;
    52.           if (++i > 2)

static int ct_base64_decode(const char *in, unsigned char **out)
{
    size_t inlen = strlen(in);
    int outlen, i;
    unsigned char *outbuf = NULL;
    if (inlen == 0) {
        *out = NULL;
        return 0;
    }
    outlen = (inlen / 4) * 3;
    outbuf = OPENSSL_malloc(outlen);
    if (outbuf == NULL) {
        CTerr(CT_F_CT_BASE64_DECODE, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    outlen = EVP_DecodeBlock(outbuf, (unsigned char *)in, inlen);
    if (outlen < 0) {
        CTerr(CT_F_CT_BASE64_DECODE, CT_R_BASE64_DECODE_ERROR);
        goto err;
    }
    i = 0;
    while (in[--inlen] == '=') {
        --outlen;
        if (++i > 2)
            goto err;
    }
    *out = outbuf;
    return outlen;
err:
    OPENSSL_free(outbuf);
    return -1;
}
['static int test_encode_tls_sct(void)\n{\n    const char log_id[] = "3xwuwRUAlFJHqWFoMl3cXHlZ6PfG04j8AC4LvT9012Q=";\n    const uint64_t timestamp = 1;\n    const char extensions[] = "";\n    const char signature[] = "BAMARzBAMiBIL2dRrzXbplQ2vh/WZA89v5pBQpSVkkUwKI+j5"\n            "eI+BgIhAOTtwNs6xXKx4vXoq2poBlOYfc9BAn3+/6EFUZ2J7b8I";\n    SCT *sct = NULL;\n    SETUP_CT_TEST_FIXTURE();\n    fixture.sct_list = sk_SCT_new_null();\n    if (!TEST_ptr(sct = SCT_new_from_base64(SCT_VERSION_V1, log_id,\n                                            CT_LOG_ENTRY_TYPE_X509, timestamp,\n                                            extensions, signature)))\n        return 0;\n    sk_SCT_push(fixture.sct_list, sct);\n    fixture.sct_dir = ct_dir;\n    fixture.sct_text_file = "tls1.sct";\n    EXECUTE_CT_TEST();\n}', 'SCT *SCT_new_from_base64(unsigned char version, const char *logid_base64,\n                         ct_log_entry_type_t entry_type, uint64_t timestamp,\n                         const char *extensions_base64,\n                         const char *signature_base64)\n{\n    SCT *sct = SCT_new();\n    unsigned char *dec = NULL;\n    const unsigned char* p = NULL;\n    int declen;\n    if (sct == NULL) {\n        CTerr(CT_F_SCT_NEW_FROM_BASE64, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    if (!SCT_set_version(sct, version)) {\n        CTerr(CT_F_SCT_NEW_FROM_BASE64, CT_R_SCT_UNSUPPORTED_VERSION);\n        goto err;\n    }\n    declen = ct_base64_decode(logid_base64, &dec);\n    if (declen < 0) {\n        CTerr(CT_F_SCT_NEW_FROM_BASE64, X509_R_BASE64_DECODE_ERROR);\n        goto err;\n    }\n    if (!SCT_set0_log_id(sct, dec, declen))\n        goto err;\n    dec = NULL;\n    declen = ct_base64_decode(extensions_base64, &dec);\n    if (declen < 0) {\n        CTerr(CT_F_SCT_NEW_FROM_BASE64, X509_R_BASE64_DECODE_ERROR);\n        goto err;\n    }\n    SCT_set0_extensions(sct, dec, declen);\n    dec = NULL;\n    declen = ct_base64_decode(signature_base64, &dec);\n    if (declen < 0) {\n        CTerr(CT_F_SCT_NEW_FROM_BASE64, X509_R_BASE64_DECODE_ERROR);\n        goto err;\n    }\n    p = dec;\n    if (o2i_SCT_signature(sct, &p, declen) <= 0)\n        goto err;\n    OPENSSL_free(dec);\n    dec = NULL;\n    SCT_set_timestamp(sct, timestamp);\n    if (!SCT_set_log_entry_type(sct, entry_type))\n        goto err;\n    return sct;\n err:\n    OPENSSL_free(dec);\n    SCT_free(sct);\n    return NULL;\n}', "static int ct_base64_decode(const char *in, unsigned char **out)\n{\n    size_t inlen = strlen(in);\n    int outlen, i;\n    unsigned char *outbuf = NULL;\n    if (inlen == 0) {\n        *out = NULL;\n        return 0;\n    }\n    outlen = (inlen / 4) * 3;\n    outbuf = OPENSSL_malloc(outlen);\n    if (outbuf == NULL) {\n        CTerr(CT_F_CT_BASE64_DECODE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    outlen = EVP_DecodeBlock(outbuf, (unsigned char *)in, inlen);\n    if (outlen < 0) {\n        CTerr(CT_F_CT_BASE64_DECODE, CT_R_BASE64_DECODE_ERROR);\n        goto err;\n    }\n    i = 0;\n    while (in[--inlen] == '=') {\n        --outlen;\n        if (++i > 2)\n            goto err;\n    }\n    *out = outbuf;\n    return outlen;\nerr:\n    OPENSSL_free(outbuf);\n    return -1;\n}"]