test/params_test.c:136: error: BUFFER_OVERRUN_L3
  Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_native2bn`.
Showing all 18 steps of the trace


test/params_test.c:136:18: Call
134.           } else if (strcmp(params->key, "p3") == 0) {
135.               BN_free(obj->p3);
136.               if (!TEST_ptr(obj->p3 = BN_native2bn(params->data,
                        ^
137.                                                    params->data_size, NULL)))
138.                   return 0;

crypto/bn/bn_lib.c:539:1: Parameter `*ret->d`
  537.   }
  538.   
  539. > BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)
  540.   {
  541.   #ifdef B_ENDIAN

crypto/bn/bn_lib.c:544:12: Call
  542.       return BN_bin2bn(s, len, ret);
  543.   #else
  544.       return BN_lebin2bn(s, len, ret);
                    ^
  545.   #endif
  546.   }

crypto/bn/bn_lib.c:472:1: Parameter `*ret->d`
    470.   }
    471.   
    472. > BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)
    473.   {
    474.       unsigned int i, m;

test/params_test.c:136:18: Call
134.           } else if (strcmp(params->key, "p3") == 0) {
135.               BN_free(obj->p3);
136.               if (!TEST_ptr(obj->p3 = BN_native2bn(params->data,
                        ^
137.                                                    params->data_size, NULL)))
138.                   return 0;

crypto/bn/bn_lib.c:539:1: Parameter `*ret->d`
  537.   }
  538.   
  539. > BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)
  540.   {
  541.   #ifdef B_ENDIAN

crypto/bn/bn_lib.c:544:12: Call
  542.       return BN_bin2bn(s, len, ret);
  543.   #else
  544.       return BN_lebin2bn(s, len, ret);
                    ^
  545.   #endif
  546.   }

crypto/bn/bn_lib.c:472:1: Parameter `*ret->d`
    470.   }
    471.   
    472. > BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)
    473.   {
    474.       unsigned int i, m;

crypto/bn/bn_lib.c:495:9: Call
    493.       i = ((n - 1) / BN_BYTES) + 1;
    494.       m = ((n - 1) % (BN_BYTES));
    495.       if (bn_wexpand(ret, (int)i) == NULL) {
                   ^
    496.           BN_free(bn);
    497.           return NULL;

crypto/bn/bn_lib.c:960:1: Parameter `*a->d`
      958.   }
      959.   
      960. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
      961.   {
      962.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_lib.c:962:37: Call
      960.   BIGNUM *bn_wexpand(BIGNUM *a, int words)
      961.   {
      962.       return (words <= a->dmax) ? a : bn_expand2(a, words);
                                                 ^
      963.   }
      964.   

crypto/bn/bn_lib.c:245:1: Parameter `*b->d`
        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 `*b->d`
          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:232:9: Array access: Offset added: [8, +oo] Size: [0, 536870848] by call to `BN_native2bn` 
          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 raw_set_params(void *vobj, const OSSL_PARAM *params)\n{\n    struct object_st *obj = vobj;\n    for (; params->key != NULL; params++)\n        if (strcmp(params->key, "p1") == 0) {\n            obj->p1 = *(int *)params->data;\n        } else if (strcmp(params->key, "p2") == 0) {\n            obj->p2 = *(double *)params->data;\n        } else if (strcmp(params->key, "p3") == 0) {\n            BN_free(obj->p3);\n            if (!TEST_ptr(obj->p3 = BN_native2bn(params->data,\n                                                 params->data_size, NULL)))\n                return 0;\n        } else if (strcmp(params->key, "p4") == 0) {\n            OPENSSL_free(obj->p4);\n            if (!TEST_ptr(obj->p4 = OPENSSL_strndup(params->data,\n                                                    params->data_size)))\n                return 0;\n        } else if (strcmp(params->key, "p5") == 0) {\n            strncpy(obj->p5, params->data, params->data_size);\n        } else if (strcmp(params->key, "p6") == 0) {\n            obj->p6 = *(const char **)params->data;\n        }\n    return 1;\n}', 'BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n#ifdef B_ENDIAN\n    return BN_bin2bn(s, len, ret);\n#else\n    return BN_lebin2bn(s, len, ret);\n#endif\n}', 'BIGNUM *BN_lebin2bn(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    s += len;\n    for ( ; len > 0 && s[-1] == 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        s--;\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    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}']