crypto/sm2/sm2_crypt.c:173: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_priv_rand_range`.
Showing all 20 steps of the trace


crypto/sm2/sm2_crypt.c:152:9: Call
150.   
151.       BN_CTX_start(ctx);
152.       k = BN_CTX_get(ctx);
               ^
153.       x1 = BN_CTX_get(ctx);
154.       x2 = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:229:5: Call
  227.       }
  228.       /* OK, make sure the returned bignum is "zero" */
  229.       BN_zero(ret);
             ^
  230.       ctx->used++;
  231.       CTXDBG_RET(ctx, ret);

crypto/bn/bn_lib.c:365:15: Assignment
    363.       a->neg = 0;
    364.       a->d[0] = w;
    365.       a->top = (w ? 1 : 0);
                         ^
    366.       a->flags &= ~BN_FLG_FIXED_TOP;
    367.       bn_check_top(a);

crypto/bn/bn_lib.c:365:5: Assignment
    363.       a->neg = 0;
    364.       a->d[0] = w;
    365.       a->top = (w ? 1 : 0);
               ^
    366.       a->flags &= ~BN_FLG_FIXED_TOP;
    367.       bn_check_top(a);

crypto/sm2/sm2_crypt.c:173:10: Call
171.       memset(ciphertext_buf, 0, *ciphertext_len);
172.   
173.       if (!BN_priv_rand_range(k, order)) {
                ^
174.           SM2err(SM2_F_SM2_ENCRYPT, ERR_R_INTERNAL_ERROR);
175.           goto done;

crypto/bn/bn_rand.c:182:1: Parameter `*r->d`
  180.   }
  181.   
  182. > int BN_priv_rand_range(BIGNUM *r, const BIGNUM *range)
  183.   {
  184.       return bnrand_range(PRIVATE, r, range);

crypto/bn/bn_rand.c:184:12: Call
  182.   int BN_priv_rand_range(BIGNUM *r, const BIGNUM *range)
  183.   {
  184.       return bnrand_range(PRIVATE, r, range);
                    ^
  185.   }
  186.   

crypto/bn/bn_rand.c:113:1: Parameter `*r->d`
    111.   
    112.   /* random number r:  0 <= r < range */
    113. > static int bnrand_range(BNRAND_FLAG flag, BIGNUM *r, const BIGNUM *range)
    114.   {
    115.       int n;

crypto/bn/bn_rand.c:128:9: Call
    126.   
    127.       if (n == 1)
    128.           BN_zero(r);
                   ^
    129.       else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {
    130.           /*

crypto/bn/bn_lib.c:358:1: Parameter `*a->d`
      356.   }
      357.   
      358. > int BN_set_word(BIGNUM *a, BN_ULONG w)
      359.   {
      360.       bn_check_top(a);

crypto/bn/bn_lib.c:361:9: Call
      359.   {
      360.       bn_check_top(a);
      361.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                     ^
      362.           return 0;
      363.       a->neg = 0;

crypto/bn/bn_lcl.h:660:1: Parameter `*a->d`
        658.                            const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx);
        659.   
        660. > static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
        661.   {
        662.       if (bits > (INT_MAX - BN_BITS2 + 1))

crypto/bn/bn_lcl.h:668:12: Call
        666.           return a;
        667.   
        668.       return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
                          ^
        669.   }
        670.   

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

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

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

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

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

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

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