apps/ts.c:806: error: BUFFER_OVERRUN_L3
  Offset: 0 Size: [0, 8388607] by call to `BN_add_word`.
Showing all 9 steps of the trace


apps/ts.c:802:19: Call
800.               goto err;
801.           }
802.           if ((bn = ASN1_INTEGER_to_BN(serial, NULL)) == NULL)
                         ^
803.               goto err;
804.           ASN1_INTEGER_free(serial);

crypto/asn1/a_int.c:629:12: Call
  627.   BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
  628.   {
  629.       return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);
                    ^
  630.   }
  631.   

crypto/asn1/a_int.c:563:1: Parameter `bn->d`
    561.   }
    562.   
    563. > static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,
    564.                                    int itype)
    565.   {

apps/ts.c:806:14: Call
804.           ASN1_INTEGER_free(serial);
805.           serial = NULL;
806.           if (!BN_add_word(bn, 1))
                    ^
807.               goto err;
808.           if ((serial = BN_to_ASN1_INTEGER(bn, NULL)) == NULL)

crypto/bn/bn_word.c:123:1: Parameter `*a->d`
  121.   }
  122.   
  123. > int BN_add_word(BIGNUM *a, BN_ULONG w)
  124.   {
  125.       BN_ULONG l;

crypto/bn/bn_word.c:140:13: Call
  138.       if (a->neg) {
  139.           a->neg = 0;
  140.           i = BN_sub_word(a, w);
                     ^
  141.           if (!BN_is_zero(a))
  142.               a->neg = !(a->neg);

crypto/bn/bn_word.c:159:1: <Length trace>
157.   }
158.   
159. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
160.   {
161.       int i;

crypto/bn/bn_word.c:159:1: Parameter `*a->d`
    157.   }
    158.   
    159. > int BN_sub_word(BIGNUM *a, BN_ULONG w)
    160.   {
    161.       int i;

crypto/bn/bn_word.c:184:27: Array access: Offset: 0 Size: [0, 8388607] by call to `BN_add_word` 
    182.       }
    183.   
    184.       if ((a->top == 1) && (a->d[0] < w)) {
                                     ^
    185.           a->d[0] = w - a->d[0];
    186.           a->neg = 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);
}
['static ASN1_INTEGER *next_serial(const char *serialfile)\n{\n    int ret = 0;\n    BIO *in = NULL;\n    ASN1_INTEGER *serial = NULL;\n    BIGNUM *bn = NULL;\n    if ((serial = ASN1_INTEGER_new()) == NULL)\n        goto err;\n    if ((in = BIO_new_file(serialfile, "r")) == NULL) {\n        ERR_clear_error();\n        BIO_printf(bio_err, "Warning: could not open file %s for "\n                   "reading, using serial number: 1\\n", serialfile);\n        if (!ASN1_INTEGER_set(serial, 1))\n            goto err;\n    } else {\n        char buf[1024];\n        if (!a2i_ASN1_INTEGER(in, serial, buf, sizeof(buf))) {\n            BIO_printf(bio_err, "unable to load number from %s\\n",\n                       serialfile);\n            goto err;\n        }\n        if ((bn = ASN1_INTEGER_to_BN(serial, NULL)) == NULL)\n            goto err;\n        ASN1_INTEGER_free(serial);\n        serial = NULL;\n        if (!BN_add_word(bn, 1))\n            goto err;\n        if ((serial = BN_to_ASN1_INTEGER(bn, NULL)) == NULL)\n            goto err;\n    }\n    ret = 1;\n err:\n    if (!ret) {\n        ASN1_INTEGER_free(serial);\n        serial = NULL;\n    }\n    BIO_free_all(in);\n    BN_free(bn);\n    return serial;\n}', 'BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)\n{\n    return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);\n}', 'static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,\n                                 int itype)\n{\n    BIGNUM *ret;\n    if ((ai->type & ~V_ASN1_NEG) != itype) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);\n        return NULL;\n    }\n    ret = BN_bin2bn(ai->data, ai->length, bn);\n    if (ret == 0) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_BN_LIB);\n        return NULL;\n    }\n    if (ai->type & V_ASN1_NEG)\n        BN_set_negative(ret, 1);\n    return ret;\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}']