crypto/asn1/a_d2i_fp.c:118: error: BUFFER_OVERRUN_L3
  Offset: [2, +oo] Size: [1, 2147483644] by call to `ASN1_item_d2i`.
Showing all 24 steps of the trace


crypto/asn1/a_d2i_fp.c:113:11: Call
111.       int len;
112.   
113.       len = asn1_d2i_read_bio(in, &b);
                 ^
114.       if (len < 0)
115.           goto err;

crypto/asn1/a_d2i_fp.c:167:38: Call
  165.               want -= (len - off);
  166.   
  167.               if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) {
                                              ^
  168.                   ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE);
  169.                   goto err;

crypto/buffer/buffer.c:158:1: Parameter `*str->data`
    156.   }
    157.   
    158. > size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
    159.   {
    160.       char *ret;

crypto/asn1/a_d2i_fp.c:117:5: Assignment
115.           goto err;
116.   
117.       p = (const unsigned char *)b->data;
           ^
118.       ret = ASN1_item_d2i(x, &p, len, it);
119.    err:

crypto/asn1/a_d2i_fp.c:118:11: Call
116.   
117.       p = (const unsigned char *)b->data;
118.       ret = ASN1_item_d2i(x, &p, len, it);
                 ^
119.    err:
120.       BUF_MEM_free(b);

crypto/asn1/tasn_dec.c:144:1: Parameter `**in`
  142.    */
  143.   
  144. > ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
  145.                             const unsigned char **in, long len,
  146.                             const ASN1_ITEM *it)

crypto/asn1/tasn_dec.c:153:9: Call
  151.           pval = &ptmpval;
  152.       asn1_tlc_clear_nc(&c);
  153.       if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
                 ^
  154.           return *pval;
  155.       return NULL;

crypto/asn1/tasn_dec.c:158:1: Parameter `**in`
    156.   }
    157.   
    158. > int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
    159.                        const ASN1_ITEM *it,
    160.                        int tag, int aclass, char opt, ASN1_TLC *ctx)

crypto/asn1/tasn_dec.c:163:10: Call
    161.   {
    162.       int rv;
    163.       rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx);
                    ^
    164.       if (rv <= 0)
    165.           ASN1_item_ex_free(pval, it);

crypto/asn1/tasn_dec.c:174:1: Parameter `**in`
      172.    */
      173.   
      174. > static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
      175.                                  long len, const ASN1_ITEM *it,
      176.                                  int tag, int aclass, char opt, ASN1_TLC *ctx)

crypto/asn1/tasn_dec.c:218:9: Assignment
      216.   
      217.       case ASN1_ITYPE_MSTRING:
      218.           p = *in;
                     ^
      219.           /* Just read in tag and class */
      220.           ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,

crypto/asn1/tasn_dec.c:220:15: Call
      218.           p = *in;
      219.           /* Just read in tag and class */
      220.           ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,
                           ^
      221.                                 &p, len, -1, 0, 1, ctx);
      222.           if (!ret) {

crypto/asn1/tasn_dec.c:1098:1: Parameter `**in`
        1096.    */
        1097.   
        1098. > static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
        1099.                              char *inf, char *cst,
        1100.                              const unsigned char **in, long len,

crypto/asn1/tasn_dec.c:1107:5: Assignment
        1105.       long plen;
        1106.       const unsigned char *p, *q;
        1107.       p = *in;
                    ^
        1108.       q = p;
        1109.   

crypto/asn1/tasn_dec.c:1117:13: Call
        1115.           p += ctx->hdrlen;
        1116.       } else {
        1117.           i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);
                            ^
        1118.           if (ctx) {
        1119.               ctx->ret = i;

crypto/asn1/asn1_lib.c:92:1: Parameter `**pp`
          90.   }
          91.   
          92. > int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,
          93.                       int *pclass, long omax)
          94.   {

crypto/asn1/asn1_lib.c:97:5: Assignment
          95.       int i, ret;
          96.       long l;
          97.       const unsigned char *p = *pp;
                     ^
          98.       int tag, xclass, inf;
          99.       long max = omax;

crypto/asn1/asn1_lib.c:126:9: Assignment
          124.       } else {
          125.           tag = i;
          126.           p++;
                         ^
          127.           if (--max == 0)
          128.               goto err;

crypto/asn1/asn1_lib.c:132:10: Call
          130.       *ptag = tag;
          131.       *pclass = xclass;
          132.       if (!asn1_get_length(&p, &inf, plength, (int)max))
                          ^
          133.           goto err;
          134.   

crypto/asn1/asn1_lib.c:153:1: <Length trace>
151.   }
152.   
153. > static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
154.                              int max)
155.   {

crypto/asn1/asn1_lib.c:153:1: Parameter `**pp`
            151.   }
            152.   
            153. > static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
            154.                              int max)
            155.   {

crypto/asn1/asn1_lib.c:156:5: Assignment
            154.                              int max)
            155.   {
            156.       const unsigned char *p = *pp;
                       ^
            157.       unsigned long ret = 0;
            158.       unsigned int i;

crypto/asn1/asn1_lib.c:169:15: Assignment
            167.           *inf = 0;
            168.           i = *p & 0x7f;
            169.           if (*(p++) & 0x80) {
                                 ^
            170.               if (max < (int)i)
            171.                   return 0;

crypto/asn1/asn1_lib.c:173:25: Array access: Offset: [2, +oo] Size: [1, 2147483644] by call to `ASN1_item_d2i` 
            171.                   return 0;
            172.               /* Skip leading zeroes */
            173.               while (i && *p == 0) {
                                           ^
            174.                   p++;
            175.                   i--;

static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
                           int max)
{
    const unsigned char *p = *pp;
    unsigned long ret = 0;
    unsigned int i;
    if (max-- < 1)
        return (0);
    if (*p == 0x80) {
        *inf = 1;
        ret = 0;
        p++;
    } else {
        *inf = 0;
        i = *p & 0x7f;
        if (*(p++) & 0x80) {
            if (max < (int)i)
                return 0;
            while (i && *p == 0) {
                p++;
                i--;
            }
            if (i > sizeof(long))
                return 0;
            while (i-- > 0) {
                ret <<= 8L;
                ret |= *(p++);
            }
        } else
            ret = i;
    }
    if (ret > LONG_MAX)
        return 0;
    *pp = p;
    *rl = (long)ret;
    return (1);
}
['void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)\n{\n    BUF_MEM *b = NULL;\n    const unsigned char *p;\n    void *ret = NULL;\n    int len;\n    len = asn1_d2i_read_bio(in, &b);\n    if (len < 0)\n        goto err;\n    p = (const unsigned char *)b->data;\n    ret = ASN1_item_d2i(x, &p, len, it);\n err:\n    BUF_MEM_free(b);\n    return (ret);\n}', 'static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)\n{\n    BUF_MEM *b;\n    unsigned char *p;\n    int i;\n    size_t want = HEADER_SIZE;\n    int eos = 0;\n    size_t off = 0;\n    size_t len = 0;\n    const unsigned char *q;\n    long slen;\n    int inf, tag, xclass;\n    b = BUF_MEM_new();\n    if (b == NULL) {\n        ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    ERR_clear_error();\n    for (;;) {\n        if (want >= (len - off)) {\n            want -= (len - off);\n            if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) {\n                ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            i = BIO_read(in, &(b->data[len]), want);\n            if ((i < 0) && ((len - off) == 0)) {\n                ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_NOT_ENOUGH_DATA);\n                goto err;\n            }\n            if (i > 0) {\n                if (len + i < len) {\n                    ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG);\n                    goto err;\n                }\n                len += i;\n            }\n        }\n        p = (unsigned char *)&(b->data[off]);\n        q = p;\n        inf = ASN1_get_object(&q, &slen, &tag, &xclass, len - off);\n        if (inf & 0x80) {\n            unsigned long e;\n            e = ERR_GET_REASON(ERR_peek_error());\n            if (e != ASN1_R_TOO_LONG)\n                goto err;\n            else\n                ERR_clear_error();\n        }\n        i = q - p;\n        off += i;\n        if (inf & 1) {\n            eos++;\n            if (eos < 0) {\n                ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_HEADER_TOO_LONG);\n                goto err;\n            }\n            want = HEADER_SIZE;\n        } else if (eos && (slen == 0) && (tag == V_ASN1_EOC)) {\n            eos--;\n            if (eos <= 0)\n                break;\n            else\n                want = HEADER_SIZE;\n        } else {\n            want = slen;\n            if (want > (len - off)) {\n                want -= (len - off);\n                if (want > INT_MAX    ||\n                    len + want < len) {\n                    ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG);\n                    goto err;\n                }\n                if (!BUF_MEM_grow_clean(b, len + want)) {\n                    ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ERR_R_MALLOC_FAILURE);\n                    goto err;\n                }\n                while (want > 0) {\n                    i = BIO_read(in, &(b->data[len]), want);\n                    if (i <= 0) {\n                        ASN1err(ASN1_F_ASN1_D2I_READ_BIO,\n                                ASN1_R_NOT_ENOUGH_DATA);\n                        goto err;\n                    }\n                    len += i;\n                    want -= i;\n                }\n            }\n            if (off + slen < off) {\n                ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG);\n                goto err;\n            }\n            off += slen;\n            if (eos <= 0) {\n                break;\n            } else\n                want = HEADER_SIZE;\n        }\n    }\n    if (off > INT_MAX) {\n        ASN1err(ASN1_F_ASN1_D2I_READ_BIO, ASN1_R_TOO_LONG);\n        goto err;\n    }\n    *pb = b;\n    return off;\n err:\n    BUF_MEM_free(b);\n    return -1;\n}', 'size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len)\n{\n    char *ret;\n    size_t n;\n    if (str->length >= len) {\n        memset(&str->data[len], 0, str->length - len);\n        str->length = len;\n        return (len);\n    }\n    if (str->max >= len) {\n        memset(&str->data[str->length], 0, len - str->length);\n        str->length = len;\n        return (len);\n    }\n    if (len > LIMIT_BEFORE_EXPANSION) {\n        BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    n = (len + 3) / 3 * 4;\n    if ((str->flags & BUF_MEM_FLAG_SECURE))\n        ret = sec_alloc_realloc(str, n);\n    else\n        ret = OPENSSL_clear_realloc(str->data, str->max, n);\n    if (ret == NULL) {\n        BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE);\n        len = 0;\n    } else {\n        str->data = ret;\n        str->max = n;\n        memset(&str->data[str->length], 0, len - str->length);\n        str->length = len;\n    }\n    return (len);\n}', 'ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,\n                          const unsigned char **in, long len,\n                          const ASN1_ITEM *it)\n{\n    ASN1_TLC c;\n    ASN1_VALUE *ptmpval = NULL;\n    if (!pval)\n        pval = &ptmpval;\n    asn1_tlc_clear_nc(&c);\n    if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)\n        return *pval;\n    return NULL;\n}', 'int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,\n                     const ASN1_ITEM *it,\n                     int tag, int aclass, char opt, ASN1_TLC *ctx)\n{\n    int rv;\n    rv = asn1_item_embed_d2i(pval, in, len, it, tag, aclass, opt, ctx);\n    if (rv <= 0)\n        ASN1_item_ex_free(pval, it);\n    return rv;\n}', 'static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,\n                               long len, const ASN1_ITEM *it,\n                               int tag, int aclass, char opt, ASN1_TLC *ctx)\n{\n    const ASN1_TEMPLATE *tt, *errtt = NULL;\n    const ASN1_EXTERN_FUNCS *ef;\n    const ASN1_AUX *aux = it->funcs;\n    ASN1_aux_cb *asn1_cb;\n    const unsigned char *p = NULL, *q;\n    unsigned char oclass;\n    char seq_eoc, seq_nolen, cst, isopt;\n    long tmplen;\n    int i;\n    int otag;\n    int ret = 0;\n    ASN1_VALUE **pchptr;\n    if (!pval)\n        return 0;\n    if (aux && aux->asn1_cb)\n        asn1_cb = aux->asn1_cb;\n    else\n        asn1_cb = 0;\n    switch (it->itype) {\n    case ASN1_ITYPE_PRIMITIVE:\n        if (it->templates) {\n            if ((tag != -1) || opt) {\n                ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I,\n                        ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE);\n                goto err;\n            }\n            return asn1_template_ex_d2i(pval, in, len,\n                                        it->templates, opt, ctx);\n        }\n        return asn1_d2i_ex_primitive(pval, in, len, it,\n                                     tag, aclass, opt, ctx);\n    case ASN1_ITYPE_MSTRING:\n        p = *in;\n        ret = asn1_check_tlen(NULL, &otag, &oclass, NULL, NULL,\n                              &p, len, -1, 0, 1, ctx);\n        if (!ret) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);\n            goto err;\n        }\n        if (oclass != V_ASN1_UNIVERSAL) {\n            if (opt)\n                return -1;\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_NOT_UNIVERSAL);\n            goto err;\n        }\n        if (!(ASN1_tag2bit(otag) & it->utype)) {\n            if (opt)\n                return -1;\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MSTRING_WRONG_TAG);\n            goto err;\n        }\n        return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx);\n    case ASN1_ITYPE_EXTERN:\n        ef = it->funcs;\n        return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx);\n    case ASN1_ITYPE_CHOICE:\n        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))\n            goto auxerr;\n        if (*pval) {\n            i = asn1_get_choice_selector(pval, it);\n            if ((i >= 0) && (i < it->tcount)) {\n                tt = it->templates + i;\n                pchptr = asn1_get_field_ptr(pval, tt);\n                asn1_template_free(pchptr, tt);\n                asn1_set_choice_selector(pval, -1, it);\n            }\n        } else if (!ASN1_item_ex_new(pval, it)) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);\n            goto err;\n        }\n        p = *in;\n        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {\n            pchptr = asn1_get_field_ptr(pval, tt);\n            ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx);\n            if (ret == -1)\n                continue;\n            if (ret > 0)\n                break;\n            errtt = tt;\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);\n            goto err;\n        }\n        if (i == it->tcount) {\n            if (opt) {\n                ASN1_item_ex_free(pval, it);\n                return -1;\n            }\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_NO_MATCHING_CHOICE_TYPE);\n            goto err;\n        }\n        asn1_set_choice_selector(pval, i, it);\n        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))\n            goto auxerr;\n        *in = p;\n        return 1;\n    case ASN1_ITYPE_NDEF_SEQUENCE:\n    case ASN1_ITYPE_SEQUENCE:\n        p = *in;\n        tmplen = len;\n        if (tag == -1) {\n            tag = V_ASN1_SEQUENCE;\n            aclass = V_ASN1_UNIVERSAL;\n        }\n        ret = asn1_check_tlen(&len, NULL, NULL, &seq_eoc, &cst,\n                              &p, len, tag, aclass, opt, ctx);\n        if (!ret) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);\n            goto err;\n        } else if (ret == -1)\n            return -1;\n        if (aux && (aux->flags & ASN1_AFLG_BROKEN)) {\n            len = tmplen - (p - *in);\n            seq_nolen = 1;\n        }\n        else\n            seq_nolen = seq_eoc;\n        if (!cst) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_NOT_CONSTRUCTED);\n            goto err;\n        }\n        if (!*pval && !ASN1_item_ex_new(pval, it)) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);\n            goto err;\n        }\n        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_PRE, pval, it, NULL))\n            goto auxerr;\n        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {\n            if (tt->flags & ASN1_TFLG_ADB_MASK) {\n                const ASN1_TEMPLATE *seqtt;\n                ASN1_VALUE **pseqval;\n                seqtt = asn1_do_adb(pval, tt, 1);\n                pseqval = asn1_get_field_ptr(pval, seqtt);\n                asn1_template_free(pseqval, seqtt);\n            }\n        }\n        for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {\n            const ASN1_TEMPLATE *seqtt;\n            ASN1_VALUE **pseqval;\n            seqtt = asn1_do_adb(pval, tt, 1);\n            if (!seqtt)\n                goto err;\n            pseqval = asn1_get_field_ptr(pval, seqtt);\n            if (!len)\n                break;\n            q = p;\n            if (asn1_check_eoc(&p, len)) {\n                if (!seq_eoc) {\n                    ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_UNEXPECTED_EOC);\n                    goto err;\n                }\n                len -= p - q;\n                seq_eoc = 0;\n                q = p;\n                break;\n            }\n            if (i == (it->tcount - 1))\n                isopt = 0;\n            else\n                isopt = (char)(seqtt->flags & ASN1_TFLG_OPTIONAL);\n            ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx);\n            if (!ret) {\n                errtt = seqtt;\n                goto err;\n            } else if (ret == -1) {\n                asn1_template_free(pseqval, seqtt);\n                continue;\n            }\n            len -= p - q;\n        }\n        if (seq_eoc && !asn1_check_eoc(&p, len)) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_MISSING_EOC);\n            goto err;\n        }\n        if (!seq_nolen && len) {\n            ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_SEQUENCE_LENGTH_MISMATCH);\n            goto err;\n        }\n        for (; i < it->tcount; tt++, i++) {\n            const ASN1_TEMPLATE *seqtt;\n            seqtt = asn1_do_adb(pval, tt, 1);\n            if (!seqtt)\n                goto err;\n            if (seqtt->flags & ASN1_TFLG_OPTIONAL) {\n                ASN1_VALUE **pseqval;\n                pseqval = asn1_get_field_ptr(pval, seqtt);\n                asn1_template_free(pseqval, seqtt);\n            } else {\n                errtt = seqtt;\n                ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_FIELD_MISSING);\n                goto err;\n            }\n        }\n        if (!asn1_enc_save(pval, *in, p - *in, it))\n            goto auxerr;\n        if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))\n            goto auxerr;\n        *in = p;\n        return 1;\n    default:\n        return 0;\n    }\n auxerr:\n    ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ASN1_R_AUX_ERROR);\n err:\n    if (errtt)\n        ERR_add_error_data(4, "Field=", errtt->field_name,\n                           ", Type=", it->sname);\n    else\n        ERR_add_error_data(2, "Type=", it->sname);\n    return 0;\n}', 'static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,\n                           char *inf, char *cst,\n                           const unsigned char **in, long len,\n                           int exptag, int expclass, char opt, ASN1_TLC *ctx)\n{\n    int i;\n    int ptag, pclass;\n    long plen;\n    const unsigned char *p, *q;\n    p = *in;\n    q = p;\n    if (ctx && ctx->valid) {\n        i = ctx->ret;\n        plen = ctx->plen;\n        pclass = ctx->pclass;\n        ptag = ctx->ptag;\n        p += ctx->hdrlen;\n    } else {\n        i = ASN1_get_object(&p, &plen, &ptag, &pclass, len);\n        if (ctx) {\n            ctx->ret = i;\n            ctx->plen = plen;\n            ctx->pclass = pclass;\n            ctx->ptag = ptag;\n            ctx->hdrlen = p - q;\n            ctx->valid = 1;\n            if (!(i & 0x81) && ((plen + ctx->hdrlen) > len)) {\n                ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_TOO_LONG);\n                asn1_tlc_clear(ctx);\n                return 0;\n            }\n        }\n    }\n    if (i & 0x80) {\n        ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_BAD_OBJECT_HEADER);\n        asn1_tlc_clear(ctx);\n        return 0;\n    }\n    if (exptag >= 0) {\n        if ((exptag != ptag) || (expclass != pclass)) {\n            if (opt)\n                return -1;\n            asn1_tlc_clear(ctx);\n            ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG);\n            return 0;\n        }\n        asn1_tlc_clear(ctx);\n    }\n    if (i & 1)\n        plen = len - (p - q);\n    if (inf)\n        *inf = i & 1;\n    if (cst)\n        *cst = i & V_ASN1_CONSTRUCTED;\n    if (olen)\n        *olen = plen;\n    if (oclass)\n        *oclass = pclass;\n    if (otag)\n        *otag = ptag;\n    *in = p;\n    return 1;\n}', 'int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag,\n                    int *pclass, long omax)\n{\n    int i, ret;\n    long l;\n    const unsigned char *p = *pp;\n    int tag, xclass, inf;\n    long max = omax;\n    if (!max)\n        goto err;\n    ret = (*p & V_ASN1_CONSTRUCTED);\n    xclass = (*p & V_ASN1_PRIVATE);\n    i = *p & V_ASN1_PRIMITIVE_TAG;\n    if (i == V_ASN1_PRIMITIVE_TAG) {\n        p++;\n        if (--max == 0)\n            goto err;\n        l = 0;\n        while (*p & 0x80) {\n            l <<= 7L;\n            l |= *(p++) & 0x7f;\n            if (--max == 0)\n                goto err;\n            if (l > (INT_MAX >> 7L))\n                goto err;\n        }\n        l <<= 7L;\n        l |= *(p++) & 0x7f;\n        tag = (int)l;\n        if (--max == 0)\n            goto err;\n    } else {\n        tag = i;\n        p++;\n        if (--max == 0)\n            goto err;\n    }\n    *ptag = tag;\n    *pclass = xclass;\n    if (!asn1_get_length(&p, &inf, plength, (int)max))\n        goto err;\n    if (inf && !(ret & V_ASN1_CONSTRUCTED))\n        goto err;\n    if (*plength > (omax - (p - *pp))) {\n        ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_TOO_LONG);\n        ret |= 0x80;\n    }\n    *pp = p;\n    return (ret | inf);\n err:\n    ASN1err(ASN1_F_ASN1_GET_OBJECT, ASN1_R_HEADER_TOO_LONG);\n    return (0x80);\n}', 'static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,\n                           int max)\n{\n    const unsigned char *p = *pp;\n    unsigned long ret = 0;\n    unsigned int i;\n    if (max-- < 1)\n        return (0);\n    if (*p == 0x80) {\n        *inf = 1;\n        ret = 0;\n        p++;\n    } else {\n        *inf = 0;\n        i = *p & 0x7f;\n        if (*(p++) & 0x80) {\n            if (max < (int)i)\n                return 0;\n            while (i && *p == 0) {\n                p++;\n                i--;\n            }\n            if (i > sizeof(long))\n                return 0;\n            while (i-- > 0) {\n                ret <<= 8L;\n                ret |= *(p++);\n            }\n        } else\n            ret = i;\n    }\n    if (ret > LONG_MAX)\n        return 0;\n    *pp = p;\n    *rl = (long)ret;\n    return (1);\n}']