test/enginetest.c:233: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_bin2bn`.
Showing all 14 steps of the trace


test/enginetest.c:232:28: Call
230.       }
231.   
232.       if (!RSA_set0_key(rsa, BN_bin2bn(n, sizeof(n)-1, NULL),
                                  ^
233.                         BN_bin2bn(e, sizeof(e)-1, NULL), NULL)) {
234.           EVP_PKEY_free(pk);

crypto/bn/bn_lib.c:410:1: Parameter `*ret->d`
  408.   }
  409.   
  410. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  411.   {
  412.       unsigned int i, m;

test/enginetest.c:233:23: Call
231.   
232.       if (!RSA_set0_key(rsa, BN_bin2bn(n, sizeof(n)-1, NULL),
233.                         BN_bin2bn(e, sizeof(e)-1, NULL), NULL)) {
                             ^
234.           EVP_PKEY_free(pk);
235.           return NULL;

crypto/bn/bn_lib.c:410:1: Parameter `*ret->d`
  408.   }
  409.   
  410. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
  411.   {
  412.       unsigned int i, m;

crypto/bn/bn_lib.c:432:9: Call
  430.       i = ((n - 1) / BN_BYTES) + 1;
  431.       m = ((n - 1) % (BN_BYTES));
  432.       if (bn_wexpand(ret, (int)i) == NULL) {
                 ^
  433.           BN_free(bn);
  434.           return NULL;

crypto/bn/bn_lib.c:951:1: Parameter `*a->d`
    949.   }
    950.   
    951. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
    952.   {
    953.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:953:37: Call
    951.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
    952.   {
    953.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                               ^
    954.   }
    955.   

crypto/bn/bn_lib.c:284:1: Parameter `*b->d`
      282.    */
      283.   
      284. > BIGNUM *bn_expand2(BIGNUM *b, int words)
      285.   {
      286.       bn_check_top(b);

crypto/bn/bn_lib.c:289:23: Call
      287.   
      288.       if (words > b->dmax) {
      289.           BN_ULONG *a = bn_expand_internal(b, words);
                                   ^
      290.           if (!a)
      291.               return NULL;

crypto/bn/bn_lib.c:246:1: <Offset trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `b->top`
        244.   /* This is used by bn_expand2() */
        245.   /* The caller MUST check that words > b->dmax before calling this */
        246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        247.   {
        248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: <Length trace>
244.   /* This is used by bn_expand2() */
245.   /* The caller MUST check that words > b->dmax before calling this */
246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
247.   {
248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:246:1: Parameter `*b->d`
        244.   /* This is used by bn_expand2() */
        245.   /* The caller MUST check that words > b->dmax before calling this */
        246. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
        247.   {
        248.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:271:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_bin2bn` 
        269.       assert(b->top <= words);
        270.       if (b->top > 0)
        271.           memcpy(a, b->d, sizeof(*a) * b->top);
                       ^
        272.   
        273.       return a;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    bn_check_top(b);
    if (words > (INT_MAX / (4 * BN_BITS2))) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
        return NULL;
    }
    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
        return (NULL);
    }
    if (BN_get_flags(b, BN_FLG_SECURE))
        a = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = OPENSSL_zalloc(words * sizeof(*a));
    if (a == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return (NULL);
    }
    assert(b->top <= words);
    if (b->top > 0)
        memcpy(a, b->d, sizeof(*a) * b->top);
    return a;
}
['static EVP_PKEY *get_test_pkey(void)\n{\n    static unsigned char n[] =\n        "\\x00\\xAA\\x36\\xAB\\xCE\\x88\\xAC\\xFD\\xFF\\x55\\x52\\x3C\\x7F\\xC4\\x52\\x3F"\n        "\\x90\\xEF\\xA0\\x0D\\xF3\\x77\\x4A\\x25\\x9F\\x2E\\x62\\xB4\\xC5\\xD9\\x9C\\xB5"\n        "\\xAD\\xB3\\x00\\xA0\\x28\\x5E\\x53\\x01\\x93\\x0E\\x0C\\x70\\xFB\\x68\\x76\\x93"\n        "\\x9C\\xE6\\x16\\xCE\\x62\\x4A\\x11\\xE0\\x08\\x6D\\x34\\x1E\\xBC\\xAC\\xA0\\xA1"\n        "\\xF5";\n    static unsigned char e[] = "\\x11";\n    RSA *rsa = RSA_new();\n    EVP_PKEY *pk = EVP_PKEY_new();\n    if (rsa == NULL || pk == NULL || !EVP_PKEY_assign_RSA(pk, rsa)) {\n        RSA_free(rsa);\n        EVP_PKEY_free(pk);\n        return NULL;\n    }\n    if (!RSA_set0_key(rsa, BN_bin2bn(n, sizeof(n)-1, NULL),\n                      BN_bin2bn(e, sizeof(e)-1, NULL), NULL)) {\n        EVP_PKEY_free(pk);\n        return NULL;\n    }\n    return pk;\n}', 'BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return (NULL);\n    bn_check_top(ret);\n    for ( ; len > 0 && *s == 0; s++, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return (ret);\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        l = (l << 8L) | *(s++);\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    bn_correct_top(ret);\n    return (ret);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}', 'BIGNUM *bn_expand2(BIGNUM *b, int words)\n{\n    bn_check_top(b);\n    if (words > b->dmax) {\n        BN_ULONG *a = bn_expand_internal(b, words);\n        if (!a)\n            return NULL;\n        if (b->d) {\n            OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));\n            bn_free_d(b);\n        }\n        b->d = a;\n        b->dmax = words;\n    }\n    bn_check_top(b);\n    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\n    bn_check_top(b);\n    if (words > (INT_MAX / (4 * BN_BITS2))) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n        return (NULL);\n    }\n    if (BN_get_flags(b, BN_FLG_SECURE))\n        a = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = OPENSSL_zalloc(words * sizeof(*a));\n    if (a == NULL) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    assert(b->top <= words);\n    if (b->top > 0)\n        memcpy(a, b->d, sizeof(*a) * b->top);\n    return a;\n}']