crypto/bn/bn_mod.c:152: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_usub`.
Showing all 9 steps of the trace


crypto/bn/bn_mod.c:149:10: Call
147.                        const BIGNUM *m)
148.   {
149.       if (!BN_uadd(r, a, b))
                ^
150.           return 0;
151.       if (BN_ucmp(r, m) >= 0)

crypto/bn/bn_add.c:152:13: Assignment
  150.           if (carry) {
  151.               /* carry != 0 => dif == 0 */
  152.               *rp = 1;
                     ^
  153.               r->top++;
  154.           }

crypto/bn/bn_mod.c:151:9: Call
149.       if (!BN_uadd(r, a, b))
150.           return 0;
151.       if (BN_ucmp(r, m) >= 0)
               ^
152.           return BN_usub(r, r, m);
153.       return 1;

crypto/bn/bn_lib.c:600:1: Parameter `*a->d`
  598.   }
  599.   
  600. > int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
  601.   {
  602.       int i;

crypto/bn/bn_mod.c:152:16: Call
150.           return 0;
151.       if (BN_ucmp(r, m) >= 0)
152.           return BN_usub(r, r, m);
                      ^
153.       return 1;
154.   }

crypto/bn/bn_add.c:166:1: <LHS trace>
164.   
165.   /* unsigned subtraction of b from a, a must be larger than b. */
166. > int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
167.   {
168.       int max, min, dif;

crypto/bn/bn_add.c:166:1: Parameter `*a->d`
  164.   
  165.   /* unsigned subtraction of b from a, a must be larger than b. */
  166. > int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
  167.   {
  168.       int max, min, dif;

crypto/bn/bn_add.c:218:13: Assignment
  216.           while (dif) {
  217.               dif--;
  218.               t1 = *(ap++);
                     ^
  219.               t2 = (t1 - 1) & BN_MASK2;
  220.               *(rp++) = t2;

crypto/bn/bn_add.c:219:13: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BN_usub` 
  217.               dif--;
  218.               t1 = *(ap++);
  219.               t2 = (t1 - 1) & BN_MASK2;
                     ^
  220.               *(rp++) = t2;
  221.               if (t1)

int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
    int max, min, dif;
    register BN_ULONG t1, t2, *rp;
    register const BN_ULONG *ap, *bp;
    int i, carry;
    bn_check_top(a);
    bn_check_top(b);
    max = a->top;
    min = b->top;
    dif = max - min;
    if (dif < 0) {
        BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3);
        return (0);
    }
    if (bn_wexpand(r, max) == NULL)
        return (0);
    ap = a->d;
    bp = b->d;
    rp = r->d;
#if 1
    carry = 0;
    for (i = min; i != 0; i--) {
        t1 = *(ap++);
        t2 = *(bp++);
        if (carry) {
            carry = (t1 <= t2);
            t1 = (t1 - t2 - 1) & BN_MASK2;
        } else {
            carry = (t1 < t2);
            t1 = (t1 - t2) & BN_MASK2;
        }
        *(rp++) = t1 & BN_MASK2;
    }
#else
    carry = bn_sub_words(rp, ap, bp, min);
    ap += min;
    bp += min;
    rp += min;
#endif
    if (carry) {
        if (!dif)
            return 0;
        while (dif) {
            dif--;
            t1 = *(ap++);
            t2 = (t1 - 1) & BN_MASK2;
            *(rp++) = t2;
            if (t1)
                break;
        }
    }
    if (dif)
        memcpy(rp, ap, sizeof(*rp) * dif);
    r->top = max;
    r->neg = 0;
    bn_correct_top(r);
    return (1);
}
['int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,\n                     const BIGNUM *m)\n{\n    if (!BN_uadd(r, a, b))\n        return 0;\n    if (BN_ucmp(r, m) >= 0)\n        return BN_usub(r, r, m);\n    return 1;\n}', 'int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int max, min, dif;\n    const BN_ULONG *ap, *bp;\n    BN_ULONG *rp, carry, t1, t2;\n    const BIGNUM *tmp;\n    bn_check_top(a);\n    bn_check_top(b);\n    if (a->top < b->top) {\n        tmp = a;\n        a = b;\n        b = tmp;\n    }\n    max = a->top;\n    min = b->top;\n    dif = max - min;\n    if (bn_wexpand(r, max + 1) == NULL)\n        return 0;\n    r->top = max;\n    ap = a->d;\n    bp = b->d;\n    rp = r->d;\n    carry = bn_add_words(rp, ap, bp, min);\n    rp += min;\n    ap += min;\n    bp += min;\n    if (carry) {\n        while (dif) {\n            dif--;\n            t1 = *(ap++);\n            t2 = (t1 + 1) & BN_MASK2;\n            *(rp++) = t2;\n            if (t2) {\n                carry = 0;\n                break;\n            }\n        }\n        if (carry) {\n            *rp = 1;\n            r->top++;\n        }\n    }\n    if (dif && rp != ap)\n        while (dif--)\n            *(rp++) = *(ap++);\n    r->neg = 0;\n    bn_check_top(r);\n    return 1;\n}', 'int BN_ucmp(const BIGNUM *a, const BIGNUM *b)\n{\n    int i;\n    BN_ULONG t1, t2, *ap, *bp;\n    bn_check_top(a);\n    bn_check_top(b);\n    i = a->top - b->top;\n    if (i != 0)\n        return (i);\n    ap = a->d;\n    bp = b->d;\n    for (i = a->top - 1; i >= 0; i--) {\n        t1 = ap[i];\n        t2 = bp[i];\n        if (t1 != t2)\n            return ((t1 > t2) ? 1 : -1);\n    }\n    return (0);\n}', 'int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)\n{\n    int max, min, dif;\n    register BN_ULONG t1, t2, *rp;\n    register const BN_ULONG *ap, *bp;\n    int i, carry;\n    bn_check_top(a);\n    bn_check_top(b);\n    max = a->top;\n    min = b->top;\n    dif = max - min;\n    if (dif < 0) {\n        BNerr(BN_F_BN_USUB, BN_R_ARG2_LT_ARG3);\n        return (0);\n    }\n    if (bn_wexpand(r, max) == NULL)\n        return (0);\n    ap = a->d;\n    bp = b->d;\n    rp = r->d;\n#if 1\n    carry = 0;\n    for (i = min; i != 0; i--) {\n        t1 = *(ap++);\n        t2 = *(bp++);\n        if (carry) {\n            carry = (t1 <= t2);\n            t1 = (t1 - t2 - 1) & BN_MASK2;\n        } else {\n            carry = (t1 < t2);\n            t1 = (t1 - t2) & BN_MASK2;\n        }\n        *(rp++) = t1 & BN_MASK2;\n    }\n#else\n    carry = bn_sub_words(rp, ap, bp, min);\n    ap += min;\n    bp += min;\n    rp += min;\n#endif\n    if (carry) {\n        if (!dif)\n            return 0;\n        while (dif) {\n            dif--;\n            t1 = *(ap++);\n            t2 = (t1 - 1) & BN_MASK2;\n            *(rp++) = t2;\n            if (t1)\n                break;\n        }\n    }\n    if (dif)\n        memcpy(rp, ap, sizeof(*rp) * dif);\n    r->top = max;\n    r->neg = 0;\n    bn_correct_top(r);\n    return (1);\n}']