crypto/rsa/rsa_ossl.c:211: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 67108856] by call to `BN_BLINDING_convert_ex`.
Showing all 23 steps of the trace


crypto/rsa/rsa_ossl.c:211:15: Call
209.   
210.           BN_BLINDING_lock(b);
211.           ret = BN_BLINDING_convert_ex(f, unblind, b, ctx);
                     ^
212.           BN_BLINDING_unlock(b);
213.   

crypto/bn/bn_blind.c:134:1: Parameter `b->A->top`
  132.   }
  133.   
  134. > int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
  135.   {
  136.       int ret = 1;

crypto/bn/bn_blind.c:148:15: Call
  146.           /* Fresh blinding, doesn't need updating. */
  147.           b->counter = 0;
  148.       else if (!BN_BLINDING_update(b, ctx))
                       ^
  149.           return 0;
  150.   

crypto/bn/bn_blind.c:93:1: Parameter `b->A->top`
    91.   }
    92.   
    93. > int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
    94.   {
    95.       int ret = 0;

crypto/bn/bn_blind.c:113:21: Call
    111.           if (b->m_ctx != NULL) {
    112.               if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)
    113.                   || !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))
                               ^
    114.                   goto err;
    115.           } else {

crypto/bn/bn_mont.c:37:1: Parameter `r->top`
      35.   }
      36.   
      37. > int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
      38.                             BN_MONT_CTX *mont, BN_CTX *ctx)
      39.   {

crypto/bn/bn_mont.c:46:13: Call
      44.   #if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD)
      45.       if (num > 1 && a->top == num && b->top == num) {
      46.           if (bn_wexpand(r, num) == NULL)
                        ^
      47.               return 0;
      48.           if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) {

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

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

crypto/bn/bn_lib.c:245:1: Parameter `b->top`
          243.    */
          244.   
          245. > BIGNUM *bn_expand2(BIGNUM *b, int words)
          246.   {
          247.       if (words > b->dmax) {

crypto/bn/bn_lib.c:248:23: Call
          246.   {
          247.       if (words > b->dmax) {
          248.           BN_ULONG *a = bn_expand_internal(b, words);
                                       ^
          249.           if (!a)
          250.               return NULL;

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

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

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

crypto/bn/bn_lib.c:209:1: Parameter `words`
            207.   /* This is used by bn_expand2() */
            208.   /* The caller MUST check that words > b->dmax before calling this */
            209. > static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
            210.   {
            211.       BN_ULONG *a = NULL;

crypto/bn/bn_lib.c:224:13: Call
            222.           a = OPENSSL_secure_zalloc(words * sizeof(*a));
            223.       else
            224.           a = OPENSSL_zalloc(words * sizeof(*a));
                               ^
            225.       if (a == NULL) {
            226.           BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);

crypto/mem.c:228:1: Parameter `num`
              226.   }
              227.   
              228. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
              229.   {
              230.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:230:17: Call
              228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
              229.   {
              230.       void *ret = CRYPTO_malloc(num, file, line);
                                     ^
              231.   
              232.       FAILTEST();

crypto/mem.c:201:9: Assignment
                199.   
                200.       if (num == 0)
                201.           return NULL;
                               ^
                202.   
                203.       FAILTEST();

crypto/mem.c:230:5: Assignment
              228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
              229.   {
              230.       void *ret = CRYPTO_malloc(num, file, line);
                         ^
              231.   
              232.       FAILTEST();

crypto/mem.c:235:5: Assignment
              233.       if (ret != NULL)
              234.           memset(ret, 0, num);
              235.       return ret;
                         ^
              236.   }
              237.   

crypto/bn/bn_lib.c:224:9: Assignment
            222.           a = OPENSSL_secure_zalloc(words * sizeof(*a));
            223.       else
            224.           a = OPENSSL_zalloc(words * sizeof(*a));
                           ^
            225.       if (a == NULL) {
            226.           BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);

crypto/bn/bn_lib.c:232:9: Array access: Offset added: [8, +oo] Size: [0, 67108856] by call to `BN_BLINDING_convert_ex` 
            230.       assert(b->top <= words);
            231.       if (b->top > 0)
            232.           memcpy(a, b->d, sizeof(*a) * b->top);
                           ^
            233.   
            234.       return a;

static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    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 int rsa_blinding_convert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,\n                                BN_CTX *ctx)\n{\n    if (unblind == NULL) {\n        return BN_BLINDING_convert_ex(f, NULL, b, ctx);\n    } else {\n        int ret;\n        BN_BLINDING_lock(b);\n        ret = BN_BLINDING_convert_ex(f, unblind, b, ctx);\n        BN_BLINDING_unlock(b);\n        return ret;\n    }\n}', 'int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)\n{\n    int ret = 1;\n    bn_check_top(n);\n    if ((b->A == NULL) || (b->Ai == NULL)) {\n        BNerr(BN_F_BN_BLINDING_CONVERT_EX, BN_R_NOT_INITIALIZED);\n        return 0;\n    }\n    if (b->counter == -1)\n        b->counter = 0;\n    else if (!BN_BLINDING_update(b, ctx))\n        return 0;\n    if (r != NULL && (BN_copy(r, b->Ai) == NULL))\n        return 0;\n    if (b->m_ctx != NULL)\n        ret = BN_mod_mul_montgomery(n, n, b->A, b->m_ctx, ctx);\n    else\n        ret = BN_mod_mul(n, n, b->A, b->mod, ctx);\n    return ret;\n}', 'int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    if ((b->A == NULL) || (b->Ai == NULL)) {\n        BNerr(BN_F_BN_BLINDING_UPDATE, BN_R_NOT_INITIALIZED);\n        goto err;\n    }\n    if (b->counter == -1)\n        b->counter = 0;\n    if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL &&\n        !(b->flags & BN_BLINDING_NO_RECREATE)) {\n        if (!BN_BLINDING_create_param(b, NULL, NULL, ctx, NULL, NULL))\n            goto err;\n    } else if (!(b->flags & BN_BLINDING_NO_UPDATE)) {\n        if (b->m_ctx != NULL) {\n            if (!bn_mul_mont_fixed_top(b->Ai, b->Ai, b->Ai, b->m_ctx, ctx)\n                || !bn_mul_mont_fixed_top(b->A, b->A, b->A, b->m_ctx, ctx))\n                goto err;\n        } else {\n            if (!BN_mod_mul(b->Ai, b->Ai, b->Ai, b->mod, ctx)\n                || !BN_mod_mul(b->A, b->A, b->A, b->mod, ctx))\n                goto err;\n        }\n    }\n    ret = 1;\n err:\n    if (b->counter == BN_BLINDING_COUNTER)\n        b->counter = 0;\n    return ret;\n}', 'int bn_mul_mont_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                          BN_MONT_CTX *mont, BN_CTX *ctx)\n{\n    BIGNUM *tmp;\n    int ret = 0;\n    int num = mont->N.top;\n#if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD)\n    if (num > 1 && a->top == num && b->top == num) {\n        if (bn_wexpand(r, num) == NULL)\n            return 0;\n        if (bn_mul_mont(r->d, a->d, b->d, mont->N.d, mont->n0, num)) {\n            r->neg = a->neg ^ b->neg;\n            r->top = num;\n            r->flags |= BN_FLG_FIXED_TOP;\n            return 1;\n        }\n    }\n#endif\n    if ((a->top + b->top) > 2 * num)\n        return 0;\n    BN_CTX_start(ctx);\n    tmp = BN_CTX_get(ctx);\n    if (tmp == NULL)\n        goto err;\n    bn_check_top(tmp);\n    if (a == b) {\n        if (!bn_sqr_fixed_top(tmp, a, ctx))\n            goto err;\n    } else {\n        if (!bn_mul_fixed_top(tmp, a, b, ctx))\n            goto err;\n    }\n#ifdef MONT_WORD\n    if (!bn_from_montgomery_word(r, tmp, mont))\n        goto err;\n#else\n    if (!BN_from_montgomery(r, tmp, mont, ctx))\n        goto err;\n#endif\n    ret = 1;\n err:\n    BN_CTX_end(ctx);\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    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    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\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}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']