crypto/objects/obj_dat.c:437: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_add_word`.
Showing all 10 steps of the trace


crypto/objects/obj_dat.c:446:22: Call
444.                   if (bl == NULL && (bl = BN_new()) == NULL)
445.                       goto err;
446.                   if (!BN_set_word(bl, l))
                            ^
447.                       goto err;
448.                   use_bn = 1;

crypto/bn/bn_lib.c:398:1: Parameter `*a->d`
  396.   }
  397.   
  398. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  399.   {
  400.       bn_check_top(a);

crypto/bn/bn_lib.c:401:9: Call
  399.   {
  400.       bn_check_top(a);
  401.       if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
                 ^
  402.           return (0);
  403.       a->neg = 0;

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

crypto/objects/obj_dat.c:437:22: Call
435.                   goto err;
436.               if (use_bn) {
437.                   if (!BN_add_word(bl, c & 0x7f))
                            ^
438.                       goto err;
439.               } else

crypto/bn/bn_word.c:98:1: Parameter `*a->d`
  96.   }
  97.   
  98. > int BN_add_word(BIGNUM *a, BN_ULONG w)
  99.   {
  100.       BN_ULONG l;

crypto/bn/bn_word.c:115:13: Call
  113.       if (a->neg) {
  114.           a->neg = 0;
  115.           i = BN_sub_word(a, w);
                     ^
  116.           if (!BN_is_zero(a))
  117.               a->neg = !(a->neg);

crypto/bn/bn_word.c:134:1: <Length trace>
132.   }
133.   
134. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
135.   {
136.       int i;

crypto/bn/bn_word.c:134:1: Parameter `*a->d`
    132.   }
    133.   
    134. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
    135.   {
    136.       int i;

crypto/bn/bn_word.c:160:9: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_add_word` 
    158.   
    159.       if ((a->top == 1) && (a->d[0] < w)) {
    160.           a->d[0] = w - a->d[0];
                   ^
    161.           a->neg = 1;
    162.           return 1;

int BN_sub_word(BIGNUM *a, BN_ULONG w)
{
    int i;
    bn_check_top(a);
    w &= BN_MASK2;
    if (!w)
        return 1;
    if (BN_is_zero(a)) {
        i = BN_set_word(a, w);
        if (i != 0)
            BN_set_negative(a, 1);
        return i;
    }
    if (a->neg) {
        a->neg = 0;
        i = BN_add_word(a, w);
        a->neg = 1;
        return (i);
    }
    if ((a->top == 1) && (a->d[0] < w)) {
        a->d[0] = w - a->d[0];
        a->neg = 1;
        return 1;
    }
    i = 0;
    for (;;) {
        if (a->d[i] >= w) {
            a->d[i] -= w;
            break;
        } else {
            a->d[i] = (a->d[i] - w) & BN_MASK2;
            i++;
            w = 1;
        }
    }
    if ((a->d[i] == 0) && (i == (a->top - 1)))
        a->top--;
    bn_check_top(a);
    return 1;
}
['int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)\n{\n    int i, n = 0, len, nid, first, use_bn;\n    BIGNUM *bl;\n    unsigned long l;\n    const unsigned char *p;\n    char tbuf[DECIMAL_SIZE(i) + DECIMAL_SIZE(l) + 2];\n    if (buf && buf_len > 0)\n        buf[0] = \'\\0\';\n    if ((a == NULL) || (a->data == NULL))\n        return 0;\n    if (!no_name && (nid = OBJ_obj2nid(a)) != NID_undef) {\n        const char *s;\n        s = OBJ_nid2ln(nid);\n        if (s == NULL)\n            s = OBJ_nid2sn(nid);\n        if (s) {\n            if (buf)\n                OPENSSL_strlcpy(buf, s, buf_len);\n            n = strlen(s);\n            return n;\n        }\n    }\n    len = a->length;\n    p = a->data;\n    first = 1;\n    bl = NULL;\n    while (len > 0) {\n        l = 0;\n        use_bn = 0;\n        for (;;) {\n            unsigned char c = *p++;\n            len--;\n            if ((len == 0) && (c & 0x80))\n                goto err;\n            if (use_bn) {\n                if (!BN_add_word(bl, c & 0x7f))\n                    goto err;\n            } else\n                l |= c & 0x7f;\n            if (!(c & 0x80))\n                break;\n            if (!use_bn && (l > (ULONG_MAX >> 7L))) {\n                if (bl == NULL && (bl = BN_new()) == NULL)\n                    goto err;\n                if (!BN_set_word(bl, l))\n                    goto err;\n                use_bn = 1;\n            }\n            if (use_bn) {\n                if (!BN_lshift(bl, bl, 7))\n                    goto err;\n            } else\n                l <<= 7L;\n        }\n        if (first) {\n            first = 0;\n            if (l >= 80) {\n                i = 2;\n                if (use_bn) {\n                    if (!BN_sub_word(bl, 80))\n                        goto err;\n                } else\n                    l -= 80;\n            } else {\n                i = (int)(l / 40);\n                l -= (long)(i * 40);\n            }\n            if (buf && (buf_len > 1)) {\n                *buf++ = i + \'0\';\n                *buf = \'\\0\';\n                buf_len--;\n            }\n            n++;\n        }\n        if (use_bn) {\n            char *bndec;\n            bndec = BN_bn2dec(bl);\n            if (!bndec)\n                goto err;\n            i = strlen(bndec);\n            if (buf) {\n                if (buf_len > 1) {\n                    *buf++ = \'.\';\n                    *buf = \'\\0\';\n                    buf_len--;\n                }\n                OPENSSL_strlcpy(buf, bndec, buf_len);\n                if (i > buf_len) {\n                    buf += buf_len;\n                    buf_len = 0;\n                } else {\n                    buf += i;\n                    buf_len -= i;\n                }\n            }\n            n++;\n            n += i;\n            OPENSSL_free(bndec);\n        } else {\n            BIO_snprintf(tbuf, sizeof(tbuf), ".%lu", l);\n            i = strlen(tbuf);\n            if (buf && (buf_len > 0)) {\n                OPENSSL_strlcpy(buf, tbuf, buf_len);\n                if (i > buf_len) {\n                    buf += buf_len;\n                    buf_len = 0;\n                } else {\n                    buf += i;\n                    buf_len -= i;\n                }\n            }\n            n += i;\n            l = 0;\n        }\n    }\n    BN_free(bl);\n    return n;\n err:\n    BN_free(bl);\n    return -1;\n}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return (0);\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    bn_check_top(a);\n    return 1;\n}', 'static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)\n{\n    if (bits > (INT_MAX - BN_BITS2 + 1))\n        return NULL;\n    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)\n        return a;\n    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);\n}', 'int BN_add_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG l;\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a))\n        return BN_set_word(a, w);\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_sub_word(a, w);\n        if (!BN_is_zero(a))\n            a->neg = !(a->neg);\n        return (i);\n    }\n    for (i = 0; w != 0 && i < a->top; i++) {\n        a->d[i] = l = (a->d[i] + w) & BN_MASK2;\n        w = (w > l) ? 1 : 0;\n    }\n    if (w && i == a->top) {\n        if (bn_wexpand(a, a->top + 1) == NULL)\n            return 0;\n        a->top++;\n        a->d[i] = w;\n    }\n    bn_check_top(a);\n    return 1;\n}', 'int BN_sub_word(BIGNUM *a, BN_ULONG w)\n{\n    int i;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return 1;\n    if (BN_is_zero(a)) {\n        i = BN_set_word(a, w);\n        if (i != 0)\n            BN_set_negative(a, 1);\n        return i;\n    }\n    if (a->neg) {\n        a->neg = 0;\n        i = BN_add_word(a, w);\n        a->neg = 1;\n        return (i);\n    }\n    if ((a->top == 1) && (a->d[0] < w)) {\n        a->d[0] = w - a->d[0];\n        a->neg = 1;\n        return 1;\n    }\n    i = 0;\n    for (;;) {\n        if (a->d[i] >= w) {\n            a->d[i] -= w;\n            break;\n        } else {\n            a->d[i] = (a->d[i] - w) & BN_MASK2;\n            i++;\n            w = 1;\n        }\n    }\n    if ((a->d[i] == 0) && (i == (a->top - 1)))\n        a->top--;\n    bn_check_top(a);\n    return 1;\n}']