crypto/asn1/a_object.c:131: error: BUFFER_OVERRUN_L3
  Offset: [1, +oo] Size: [0, 8388607] by call to `BN_div_word`.
Showing all 14 steps of the trace


crypto/asn1/a_object.c:95:36: Call
93.                   if (bl == NULL)
94.                       bl = BN_new();
95.                   if (bl == NULL || !BN_set_word(bl, l))
                                         ^
96.                       goto err;
97.               }

crypto/bn/bn_lib.c:463:1: Parameter `a->top`
  461.   }
  462.   
  463. > int BN_set_word(BIGNUM *a, BN_ULONG w)
  464.   {
  465.       bn_check_top(a);

crypto/asn1/a_object.c:131:30: Call
129.               }
130.               while (blsize--) {
131.                   BN_ULONG t = BN_div_word(bl, 0x80L);
                                    ^
132.                   if (t == (BN_ULONG)-1)
133.                       goto err;

crypto/bn/bn_word.c:61:1: Parameter `*a->d`
  59.   }
  60.   
  61. > BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)
  62.   {
  63.       BN_ULONG ret = 0;

crypto/bn/bn_word.c:78:10: Call
  76.       j = BN_BITS2 - BN_num_bits_word(w);
  77.       w <<= j;
  78.       if (!BN_lshift(a, a, j))
                 ^
  79.           return (BN_ULONG)-1;
  80.   

crypto/bn/bn_shift.c:81:1: <Offset trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `n`
    79.   }
    80.   
    81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
    82.   {
    83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:96:5: Assignment
    94.   
    95.       r->neg = a->neg;
    96.       nw = n / BN_BITS2;
              ^
    97.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
    98.           return (0);

crypto/bn/bn_shift.c:81:1: <Length trace>
79.   }
80.   
81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
82.   {
83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:81:1: Parameter `*r->d`
    79.   }
    80.   
    81. > int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
    82.   {
    83.       int i, nw, lb, rb;

crypto/bn/bn_shift.c:97:9: Call
    95.       r->neg = a->neg;
    96.       nw = n / BN_BITS2;
    97.       if (bn_wexpand(r, a->top + nw + 1) == NULL)
                   ^
    98.           return (0);
    99.       lb = n % BN_BITS2;

crypto/bn/bn_lib.c:1016:1: Parameter `*a->d`
      1014.   }
      1015.   
      1016. > BIGNUM *bn_wexpand(BIGNUM *a, int words)
      1017.   {
      1018.       return (words <= a->dmax) ? a : bn_expand2(a, words);

crypto/bn/bn_shift.c:102:5: Assignment
    100.       rb = BN_BITS2 - lb;
    101.       f = a->d;
    102.       t = r->d;
               ^
    103.       t[a->top + nw] = 0;
    104.       if (lb == 0)

crypto/bn/bn_shift.c:110:13: Array access: Offset: [1, +oo] Size: [0, 8388607] by call to `BN_div_word` 
    108.           for (i = a->top - 1; i >= 0; i--) {
    109.               l = f[i];
    110.               t[nw + i + 1] |= (l >> rb) & BN_MASK2;
                       ^
    111.               t[nw + i] = (l << lb) & BN_MASK2;
    112.           }

int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
{
    int i, nw, lb, rb;
    BN_ULONG *t, *f;
    BN_ULONG l;
    bn_check_top(r);
    bn_check_top(a);
    if (n < 0) {
        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);
        return 0;
    }
    r->neg = a->neg;
    nw = n / BN_BITS2;
    if (bn_wexpand(r, a->top + nw + 1) == NULL)
        return (0);
    lb = n % BN_BITS2;
    rb = BN_BITS2 - lb;
    f = a->d;
    t = r->d;
    t[a->top + nw] = 0;
    if (lb == 0)
        for (i = a->top - 1; i >= 0; i--)
            t[nw + i] = f[i];
    else
        for (i = a->top - 1; i >= 0; i--) {
            l = f[i];
            t[nw + i + 1] |= (l >> rb) & BN_MASK2;
            t[nw + i] = (l << lb) & BN_MASK2;
        }
    memset(t, 0, sizeof(*t) * nw);
    r->top = a->top + nw + 1;
    bn_correct_top(r);
    bn_check_top(r);
    return (1);
}
["int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)\n{\n    int i, first, len = 0, c, use_bn;\n    char ftmp[24], *tmp = ftmp;\n    int tmpsize = sizeof ftmp;\n    const char *p;\n    unsigned long l;\n    BIGNUM *bl = NULL;\n    if (num == 0)\n        return (0);\n    else if (num == -1)\n        num = strlen(buf);\n    p = buf;\n    c = *(p++);\n    num--;\n    if ((c >= '0') && (c <= '2')) {\n        first = c - '0';\n    } else {\n        ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_FIRST_NUM_TOO_LARGE);\n        goto err;\n    }\n    if (num <= 0) {\n        ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_MISSING_SECOND_NUMBER);\n        goto err;\n    }\n    c = *(p++);\n    num--;\n    for (;;) {\n        if (num <= 0)\n            break;\n        if ((c != '.') && (c != ' ')) {\n            ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_INVALID_SEPARATOR);\n            goto err;\n        }\n        l = 0;\n        use_bn = 0;\n        for (;;) {\n            if (num <= 0)\n                break;\n            num--;\n            c = *(p++);\n            if ((c == ' ') || (c == '.'))\n                break;\n            if ((c < '0') || (c > '9')) {\n                ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_INVALID_DIGIT);\n                goto err;\n            }\n            if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) {\n                use_bn = 1;\n                if (bl == NULL)\n                    bl = BN_new();\n                if (bl == NULL || !BN_set_word(bl, l))\n                    goto err;\n            }\n            if (use_bn) {\n                if (!BN_mul_word(bl, 10L)\n                    || !BN_add_word(bl, c - '0'))\n                    goto err;\n            } else\n                l = l * 10L + (long)(c - '0');\n        }\n        if (len == 0) {\n            if ((first < 2) && (l >= 40)) {\n                ASN1err(ASN1_F_A2D_ASN1_OBJECT,\n                        ASN1_R_SECOND_NUMBER_TOO_LARGE);\n                goto err;\n            }\n            if (use_bn) {\n                if (!BN_add_word(bl, first * 40))\n                    goto err;\n            } else\n                l += (long)first *40;\n        }\n        i = 0;\n        if (use_bn) {\n            int blsize;\n            blsize = BN_num_bits(bl);\n            blsize = (blsize + 6) / 7;\n            if (blsize > tmpsize) {\n                if (tmp != ftmp)\n                    OPENSSL_free(tmp);\n                tmpsize = blsize + 32;\n                tmp = OPENSSL_malloc(tmpsize);\n                if (tmp == NULL)\n                    goto err;\n            }\n            while (blsize--) {\n                BN_ULONG t = BN_div_word(bl, 0x80L);\n                if (t == (BN_ULONG)-1)\n                    goto err;\n                tmp[i++] = (unsigned char)t;\n            }\n        } else {\n            for (;;) {\n                tmp[i++] = (unsigned char)l & 0x7f;\n                l >>= 7L;\n                if (l == 0L)\n                    break;\n            }\n        }\n        if (out != NULL) {\n            if (len + i > olen) {\n                ASN1err(ASN1_F_A2D_ASN1_OBJECT, ASN1_R_BUFFER_TOO_SMALL);\n                goto err;\n            }\n            while (--i > 0)\n                out[len++] = tmp[i] | 0x80;\n            out[len++] = tmp[0];\n        } else\n            len += i;\n    }\n    if (tmp != ftmp)\n        OPENSSL_free(tmp);\n    BN_free(bl);\n    return (len);\n err:\n    if (tmp != ftmp)\n        OPENSSL_free(tmp);\n    BN_free(bl);\n    return (0);\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}', 'BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w)\n{\n    BN_ULONG ret = 0;\n    int i, j;\n    bn_check_top(a);\n    w &= BN_MASK2;\n    if (!w)\n        return (BN_ULONG)-1;\n    if (a->top == 0)\n        return 0;\n    j = BN_BITS2 - BN_num_bits_word(w);\n    w <<= j;\n    if (!BN_lshift(a, a, j))\n        return (BN_ULONG)-1;\n    for (i = a->top - 1; i >= 0; i--) {\n        BN_ULONG l, d;\n        l = a->d[i];\n        d = bn_div_words(ret, l, w);\n        ret = (l - ((d * w) & BN_MASK2)) & BN_MASK2;\n        a->d[i] = d;\n    }\n    if ((a->top > 0) && (a->d[a->top - 1] == 0))\n        a->top--;\n    ret >>= j;\n    bn_check_top(a);\n    return (ret);\n}', 'int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)\n{\n    int i, nw, lb, rb;\n    BN_ULONG *t, *f;\n    BN_ULONG l;\n    bn_check_top(r);\n    bn_check_top(a);\n    if (n < 0) {\n        BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT);\n        return 0;\n    }\n    r->neg = a->neg;\n    nw = n / BN_BITS2;\n    if (bn_wexpand(r, a->top + nw + 1) == NULL)\n        return (0);\n    lb = n % BN_BITS2;\n    rb = BN_BITS2 - lb;\n    f = a->d;\n    t = r->d;\n    t[a->top + nw] = 0;\n    if (lb == 0)\n        for (i = a->top - 1; i >= 0; i--)\n            t[nw + i] = f[i];\n    else\n        for (i = a->top - 1; i >= 0; i--) {\n            l = f[i];\n            t[nw + i + 1] |= (l >> rb) & BN_MASK2;\n            t[nw + i] = (l << lb) & BN_MASK2;\n        }\n    memset(t, 0, sizeof(*t) * nw);\n    r->top = a->top + nw + 1;\n    bn_correct_top(r);\n    bn_check_top(r);\n    return (1);\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}']