crypto/pem/pem_pkey.c:261: error: BUFFER_OVERRUN_L3
  Offset: [2, +oo] Size: [1, 2147483644] by call to `d2i_DHxparams`.
Showing all 27 steps of the trace


crypto/pem/pem_pkey.c:256:10: Call
254.       DH *ret = NULL;
255.   
256.       if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_DHPARAMS, bp, cb, u))
                ^
257.           return NULL;
258.       p = data;

crypto/pem/pem_lib.c:275:1: Parameter `**pdata`
  273.   }
  274.   
  275. > int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
  276.                          const char *name, BIO *bp, pem_password_cb *cb,
  277.                          void *u)

crypto/pem/pem_pkey.c:258:5: Assignment
256.       if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_DHPARAMS, bp, cb, u))
257.           return NULL;
258.       p = data;
           ^
259.   
260.       if (strcmp(nm, PEM_STRING_DHXPARAMS) == 0)

crypto/pem/pem_pkey.c:261:15: Call
259.   
260.       if (strcmp(nm, PEM_STRING_DHXPARAMS) == 0)
261.           ret = d2i_DHxparams(x, &p, len);
                     ^
262.       else
263.           ret = d2i_DHparams(x, &p, len);

crypto/dh/dh_asn1.c:130:1: Parameter `**pp`
  128.   /* Application leve function: read in X9.42 DH parameters into DH structure */
  129.   
  130. > DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length)
  131.   {
  132.       int_dhx942_dh *dhx = NULL;

crypto/dh/dh_asn1.c:137:11: Call
  135.       if (dh == NULL)
  136.           return NULL;
  137.       dhx = d2i_int_dhx(NULL, pp, length);
                   ^
  138.       if (dhx == NULL) {
  139.           DH_free(dh);

crypto/dh/dh_asn1.c:126:1: Parameter `**in`
    124.   int i2d_int_dhx(const int_dhx942_dh *a, unsigned char **pp);
    125.   
    126. > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(int_dhx942_dh, DHxparams, int_dhx)
    127.   
    128.   /* Application leve function: read in X9.42 DH parameters into DH structure */

crypto/dh/dh_asn1.c:126:1: Call
    124.   int i2d_int_dhx(const int_dhx942_dh *a, unsigned char **pp);
    125.   
    126. > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(int_dhx942_dh, DHxparams, int_dhx)
    127.   
    128.   /* Application leve function: read in X9.42 DH parameters into DH structure */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/asn1/asn1_lib.c:172:25: Array access: Offset: [2, +oo] Size: [1, 2147483644] by call to `d2i_DHxparams` 
                170.                   return 0;
                171.               /* Skip leading zeroes */
                172.               while (i && *p == 0) {
                                               ^
                173.                   p++;
                174.                   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);
}
['DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u)\n{\n    char *nm = NULL;\n    const unsigned char *p = NULL;\n    unsigned char *data = NULL;\n    long len;\n    DH *ret = NULL;\n    if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_DHPARAMS, bp, cb, u))\n        return NULL;\n    p = data;\n    if (strcmp(nm, PEM_STRING_DHXPARAMS) == 0)\n        ret = d2i_DHxparams(x, &p, len);\n    else\n        ret = d2i_DHparams(x, &p, len);\n    if (ret == NULL)\n        PEMerr(PEM_F_PEM_READ_BIO_DHPARAMS, ERR_R_ASN1_LIB);\n    OPENSSL_free(nm);\n    OPENSSL_free(data);\n    return ret;\n}', 'int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,\n                       const char *name, BIO *bp, pem_password_cb *cb,\n                       void *u)\n{\n    EVP_CIPHER_INFO cipher;\n    char *nm = NULL, *header = NULL;\n    unsigned char *data = NULL;\n    long len;\n    int ret = 0;\n    for (;;) {\n        if (!PEM_read_bio(bp, &nm, &header, &data, &len)) {\n            if (ERR_GET_REASON(ERR_peek_error()) == PEM_R_NO_START_LINE)\n                ERR_add_error_data(2, "Expecting: ", name);\n            return 0;\n        }\n        if (check_pem(nm, name))\n            break;\n        OPENSSL_free(nm);\n        OPENSSL_free(header);\n        OPENSSL_free(data);\n    }\n    if (!PEM_get_EVP_CIPHER_INFO(header, &cipher))\n        goto err;\n    if (!PEM_do_header(&cipher, data, &len, cb, u))\n        goto err;\n    *pdata = data;\n    *plen = len;\n    if (pnm)\n        *pnm = nm;\n    ret = 1;\n err:\n    if (!ret || !pnm)\n        OPENSSL_free(nm);\n    OPENSSL_free(header);\n    if (!ret)\n        OPENSSL_free(data);\n    return ret;\n}', 'DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length)\n{\n    int_dhx942_dh *dhx = NULL;\n    DH *dh = NULL;\n    dh = DH_new();\n    if (dh == NULL)\n        return NULL;\n    dhx = d2i_int_dhx(NULL, pp, length);\n    if (dhx == NULL) {\n        DH_free(dh);\n        return NULL;\n    }\n    if (a) {\n        DH_free(*a);\n        *a = dh;\n    }\n    dh->p = dhx->p;\n    dh->q = dhx->q;\n    dh->g = dhx->g;\n    dh->j = dhx->j;\n    if (dhx->vparams) {\n        dh->seed = dhx->vparams->seed->data;\n        dh->seedlen = dhx->vparams->seed->length;\n        dh->counter = dhx->vparams->counter;\n        dhx->vparams->seed->data = NULL;\n        ASN1_BIT_STRING_free(dhx->vparams->seed);\n        OPENSSL_free(dhx->vparams);\n        dhx->vparams = NULL;\n    }\n    OPENSSL_free(dhx);\n    return dh;\n}', 'IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(int_dhx942_dh, DHxparams, int_dhx)', '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}']