apps/ts.c:878: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `ASN1_INTEGER_to_BN`.
Showing all 14 steps of the trace


apps/ts.c:862:19: Call
860.       BIGNUM *bn = NULL;
861.   
862.       if ((serial = ASN1_INTEGER_new()) == NULL)
                         ^
863.           goto err;
864.   

crypto/asn1/tasn_typ.c:78:1: Call
  76.   
  77.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
  80.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_BIT_STRING)

crypto/asn1/asn1_lib.c:356:5: Assignment
    354.           return (NULL);
    355.       }
    356.       ret->length = 0;
               ^
    357.       ret->type = type;
    358.       ret->data = NULL;

apps/ts.c:873:14: Call
871.       } else {
872.           char buf[1024];
873.           if (!a2i_ASN1_INTEGER(in, serial, buf, sizeof(buf))) {
                    ^
874.               BIO_printf(bio_err, "unable to load number from %s\n",
875.                          serialfile);

crypto/asn1/f_int.c:102:1: Parameter `bs->length`
  100.   }
  101.   
  102. > int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
  103.   {
  104.       int i, j, k, m, n, again, bufsize;

apps/ts.c:878:19: Call
876.               goto err;
877.           }
878.           if ((bn = ASN1_INTEGER_to_BN(serial, NULL)) == NULL)
                         ^
879.               goto err;
880.           ASN1_INTEGER_free(serial);

crypto/asn1/a_int.c:627:1: Parameter `ai->length`
  625.   }
  626.   
  627. > BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
  628.   {
  629.       return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);

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 `ai->length`
    561.   }
    562.   
    563. > static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,
    564.                                    int itype)
    565.   {

crypto/asn1/a_int.c:573:11: Call
    571.       }
    572.   
    573.       ret = BN_bin2bn(ai->data, ai->length, bn);
                     ^
    574.       if (ret == 0) {
    575.           ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_BN_LIB);

crypto/bn/bn_lib.c:543:1: <LHS trace>
541.   }
542.   
543. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
544.   {
545.       unsigned int i, m;

crypto/bn/bn_lib.c:543:1: Parameter `len`
      541.   }
      542.   
      543. > BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
      544.   {
      545.       unsigned int i, m;

crypto/bn/bn_lib.c:556:5: Assignment
      554.       bn_check_top(ret);
      555.       l = 0;
      556.       n = len;
                 ^
      557.       if (n == 0) {
      558.           ret->top = 0;

crypto/bn/bn_lib.c:561:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ASN1_INTEGER_to_BN` 
      559.           return (ret);
      560.       }
      561.       i = ((n - 1) / BN_BYTES) + 1;
                 ^
      562.       m = ((n - 1) % (BN_BYTES));
      563.       if (bn_wexpand(ret, (int)i) == NULL) {

BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
{
    unsigned int i, m;
    unsigned int n;
    BN_ULONG l;
    BIGNUM *bn = NULL;
    if (ret == NULL)
        ret = bn = BN_new();
    if (ret == NULL)
        return (NULL);
    bn_check_top(ret);
    l = 0;
    n = len;
    if (n == 0) {
        ret->top = 0;
        return (ret);
    }
    i = ((n - 1) / BN_BYTES) + 1;
    m = ((n - 1) % (BN_BYTES));
    if (bn_wexpand(ret, (int)i) == NULL) {
        BN_free(bn);
        return NULL;
    }
    ret->top = i;
    ret->neg = 0;
    while (n--) {
        l = (l << 8L) | *(s++);
        if (m-- == 0) {
            ret->d[--i] = l;
            l = 0;
            m = BN_BYTES - 1;
        }
    }
    bn_correct_top(ret);
    return (ret);
}
['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}', 'IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)', 'ASN1_STRING *ASN1_STRING_type_new(int type)\n{\n    ASN1_STRING *ret;\n    ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL) {\n        ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->length = 0;\n    ret->type = type;\n    ret->data = NULL;\n    ret->flags = 0;\n    return (ret);\n}', "int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)\n{\n    int i, j, k, m, n, again, bufsize;\n    unsigned char *s = NULL, *sp;\n    unsigned char *bufp;\n    int num = 0, slen = 0, first = 1;\n    bs->type = V_ASN1_INTEGER;\n    bufsize = BIO_gets(bp, buf, size);\n    for (;;) {\n        if (bufsize < 1)\n            goto err;\n        i = bufsize;\n        if (buf[i - 1] == '\\n')\n            buf[--i] = '\\0';\n        if (i == 0)\n            goto err;\n        if (buf[i - 1] == '\\r')\n            buf[--i] = '\\0';\n        if (i == 0)\n            goto err;\n        again = (buf[i - 1] == '\\\\');\n        for (j = 0; j < i; j++) {\n#ifndef CHARSET_EBCDIC\n            if (!(((buf[j] >= '0') && (buf[j] <= '9')) ||\n                  ((buf[j] >= 'a') && (buf[j] <= 'f')) ||\n                  ((buf[j] >= 'A') && (buf[j] <= 'F'))))\n#else\n            if (!isxdigit(buf[j]))\n#endif\n            {\n                i = j;\n                break;\n            }\n        }\n        buf[i] = '\\0';\n        if (i < 2)\n            goto err;\n        bufp = (unsigned char *)buf;\n        if (first) {\n            first = 0;\n            if ((bufp[0] == '0') && (buf[1] == '0')) {\n                bufp += 2;\n                i -= 2;\n            }\n        }\n        k = 0;\n        i -= again;\n        if (i % 2 != 0) {\n            ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_ODD_NUMBER_OF_CHARS);\n            return 0;\n        }\n        i /= 2;\n        if (num + i > slen) {\n            sp = OPENSSL_realloc_clean(s, slen, num + i * 2);\n            if (sp == NULL) {\n                ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);\n                OPENSSL_free(s);\n                return 0;\n            }\n            s = sp;\n            slen = num + i * 2;\n        }\n        for (j = 0; j < i; j++, k += 2) {\n            for (n = 0; n < 2; n++) {\n                m = bufp[k + n];\n                if ((m >= '0') && (m <= '9'))\n                    m -= '0';\n                else if ((m >= 'a') && (m <= 'f'))\n                    m = m - 'a' + 10;\n                else if ((m >= 'A') && (m <= 'F'))\n                    m = m - 'A' + 10;\n                else {\n                    ASN1err(ASN1_F_A2I_ASN1_INTEGER,\n                            ASN1_R_NON_HEX_CHARACTERS);\n                    goto err;\n                }\n                s[num + j] <<= 4;\n                s[num + j] |= m;\n            }\n        }\n        num += i;\n        if (again)\n            bufsize = BIO_gets(bp, buf, size);\n        else\n            break;\n    }\n    bs->length = num;\n    bs->data = s;\n    return 1;\n err:\n    ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);\n    return 0;\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}', 'BIGNUM *BN_bin2bn(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    l = 0;\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    while (n--) {\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}']