apps/ca.c:1880: error: BUFFER_OVERRUN_L3
  Offset: [-529, +oo] Size: 12 by call to `X509_print_ex`.
Showing all 13 steps of the trace


apps/ca.c:1870:14: Call
1868.       /* Set the right value for the noemailDN option */
1869.       if (email_dn == 0) {
1870.           if (!X509_set_subject_name(ret, dn_subject))
                     ^
1871.               goto end;
1872.       }

crypto/x509/x509_set.c:106:1: Parameter `*x->cert_info->subject`
  104.   }
  105.   
  106. > int X509_set_subject_name(X509 *x, X509_NAME *name)
  107.   {
  108.       if ((x == NULL) || (x->cert_info == NULL))

apps/ca.c:1880:9: Call
1878.            */
1879.           certopt |= X509_FLAG_NO_SIGDUMP | X509_FLAG_NO_SIGNAME;
1880.           X509_print_ex(bio_err, ret, nameopt, certopt);
                ^
1881.       }
1882.   

crypto/asn1/t_x509.c:105:1: Parameter `*x->cert_info->validity->notBefore->data`
  103.   }
  104.   
  105. > int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,
  106.                     unsigned long cflag)
  107.   {

crypto/asn1/t_x509.c:191:14: Call
  189.           if (BIO_write(bp, "            Not Before: ", 24) <= 0)
  190.               goto err;
  191.           if (!ASN1_TIME_print(bp, X509_get_notBefore(x)))
                      ^
  192.               goto err;
  193.           if (BIO_write(bp, "\n            Not After : ", 25) <= 0)

crypto/asn1/t_x509.c:388:1: Parameter `*tm->data`
    386.   }
    387.   
    388. > int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
    389.   {
    390.       if (tm->type == V_ASN1_UTCTIME)

crypto/asn1/t_x509.c:393:16: Call
    391.           return ASN1_UTCTIME_print(bp, tm);
    392.       if (tm->type == V_ASN1_GENERALIZEDTIME)
    393.           return ASN1_GENERALIZEDTIME_print(bp, tm);
                          ^
    394.       BIO_write(bp, "Bad time value", 14);
    395.       return (0);

crypto/asn1/t_x509.c:403:1: <Offset trace>
401.   };
402.   
403. > int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
404.   {
405.       char *v;

crypto/asn1/t_x509.c:403:1: Parameter `*tm->data`
      401.   };
      402.   
      403. > int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
      404.   {
      405.       char *v;

crypto/asn1/t_x509.c:424:5: Assignment
      422.       y = (v[0] - '0') * 1000 + (v[1] - '0') * 100
      423.           + (v[2] - '0') * 10 + (v[3] - '0');
      424.       M = (v[4] - '0') * 10 + (v[5] - '0');
                 ^
      425.       if ((M > 12) || (M < 1))
      426.           goto err;

crypto/asn1/t_x509.c:398:1: <Length trace>
396.   }
397.   
398. > static const char *mon[12] = {
399.       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
400.       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

crypto/asn1/t_x509.c:398:1: Array declaration
      396.   }
      397.   
      398. > static const char *mon[12] = {
      399.       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
      400.       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

crypto/asn1/t_x509.c:445:20: Array access: Offset: [-529, +oo] Size: 12 by call to `X509_print_ex` 
      443.   
      444.       if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
      445.                      mon[M - 1], d, h, m, s, f_len, f, y,
                                ^
      446.                      (gmt) ? " GMT" : "") <= 0)
      447.           return (0);

int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)
{
    char *v;
    int gmt = 0;
    int i;
    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;
    char *f = NULL;
    int f_len = 0;
    i = tm->length;
    v = (char *)tm->data;
    if (i < 12)
        goto err;
    if (v[i - 1] == 'Z')
        gmt = 1;
    for (i = 0; i < 12; i++)
        if ((v[i] > '9') || (v[i] < '0'))
            goto err;
    y = (v[0] - '0') * 1000 + (v[1] - '0') * 100
        + (v[2] - '0') * 10 + (v[3] - '0');
    M = (v[4] - '0') * 10 + (v[5] - '0');
    if ((M > 12) || (M < 1))
        goto err;
    d = (v[6] - '0') * 10 + (v[7] - '0');
    h = (v[8] - '0') * 10 + (v[9] - '0');
    m = (v[10] - '0') * 10 + (v[11] - '0');
    if (tm->length >= 14 &&
        (v[12] >= '0') && (v[12] <= '9') &&
        (v[13] >= '0') && (v[13] <= '9')) {
        s = (v[12] - '0') * 10 + (v[13] - '0');
        if (tm->length >= 15 && v[14] == '.') {
            int l = tm->length;
            f = &v[14];
            f_len = 1;
            while (14 + f_len < l && f[f_len] >= '0' && f[f_len] <= '9')
                ++f_len;
        }
    }
    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
                   mon[M - 1], d, h, m, s, f_len, f, y,
                   (gmt) ? " GMT" : "") <= 0)
        return (0);
    else
        return (1);
 err:
    BIO_write(bp, "Bad time value", 14);
    return (0);
}
['static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,\n                   const EVP_MD *dgst, STACK_OF(OPENSSL_STRING) *sigopts,\n                   STACK_OF(CONF_VALUE) *policy, CA_DB *db, BIGNUM *serial,\n                   char *subj, unsigned long chtype, int multirdn,\n                   int email_dn, char *startdate, char *enddate, long days,\n                   int batch, int verbose, X509_REQ *req, char *ext_sect,\n                   CONF *lconf, unsigned long certopt, unsigned long nameopt,\n                   int default_op, int ext_copy, int selfsign)\n{\n    X509_NAME *name = NULL, *CAname = NULL, *subject = NULL, *dn_subject =\n        NULL;\n    ASN1_UTCTIME *tm, *tmptm;\n    ASN1_STRING *str, *str2;\n    ASN1_OBJECT *obj;\n    X509 *ret = NULL;\n    X509_CINF *ci;\n    X509_NAME_ENTRY *ne;\n    X509_NAME_ENTRY *tne, *push;\n    EVP_PKEY *pktmp;\n    int ok = -1, i, j, last, nid;\n    const char *p;\n    CONF_VALUE *cv;\n    OPENSSL_STRING row[DB_NUMBER];\n    OPENSSL_STRING *irow = NULL;\n    OPENSSL_STRING *rrow = NULL;\n    char buf[25];\n    tmptm = ASN1_UTCTIME_new();\n    if (tmptm == NULL) {\n        BIO_printf(bio_err, "malloc error\\n");\n        return (0);\n    }\n    for (i = 0; i < DB_NUMBER; i++)\n        row[i] = NULL;\n    if (subj) {\n        X509_NAME *n = parse_name(subj, chtype, multirdn);\n        if (!n) {\n            ERR_print_errors(bio_err);\n            goto end;\n        }\n        X509_REQ_set_subject_name(req, n);\n        req->req_info->enc.modified = 1;\n        X509_NAME_free(n);\n    }\n    if (default_op)\n        BIO_printf(bio_err,\n                   "The Subject\'s Distinguished Name is as follows\\n");\n    name = X509_REQ_get_subject_name(req);\n    for (i = 0; i < X509_NAME_entry_count(name); i++) {\n        ne = X509_NAME_get_entry(name, i);\n        str = X509_NAME_ENTRY_get_data(ne);\n        obj = X509_NAME_ENTRY_get_object(ne);\n        if (msie_hack) {\n            nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(ne));\n            if (str->type == V_ASN1_UNIVERSALSTRING)\n                ASN1_UNIVERSALSTRING_to_string(str);\n            if ((str->type == V_ASN1_IA5STRING) &&\n                (nid != NID_pkcs9_emailAddress))\n                str->type = V_ASN1_T61STRING;\n            if ((nid == NID_pkcs9_emailAddress) &&\n                (str->type == V_ASN1_PRINTABLESTRING))\n                str->type = V_ASN1_IA5STRING;\n        }\n        if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) && (!email_dn))\n            continue;\n        if ((OBJ_obj2nid(obj) == NID_pkcs9_emailAddress) &&\n            (str->type != V_ASN1_IA5STRING)) {\n            BIO_printf(bio_err,\n                       "\\nemailAddress type needs to be of type IA5STRING\\n");\n            goto end;\n        }\n        if ((str->type != V_ASN1_BMPSTRING)\n            && (str->type != V_ASN1_UTF8STRING)) {\n            j = ASN1_PRINTABLE_type(str->data, str->length);\n            if (((j == V_ASN1_T61STRING) &&\n                 (str->type != V_ASN1_T61STRING)) ||\n                ((j == V_ASN1_IA5STRING) &&\n                 (str->type == V_ASN1_PRINTABLESTRING))) {\n                BIO_printf(bio_err,\n                           "\\nThe string contains characters that are illegal for the ASN.1 type\\n");\n                goto end;\n            }\n        }\n        if (default_op)\n            old_entry_print(obj, str);\n    }\n    if ((subject = X509_NAME_new()) == NULL) {\n        BIO_printf(bio_err, "Memory allocation failure\\n");\n        goto end;\n    }\n    if (selfsign)\n        CAname = X509_NAME_dup(name);\n    else\n        CAname = X509_NAME_dup(x509->cert_info->subject);\n    if (CAname == NULL)\n        goto end;\n    str = str2 = NULL;\n    for (i = 0; i < sk_CONF_VALUE_num(policy); i++) {\n        cv = sk_CONF_VALUE_value(policy, i);\n        if ((j = OBJ_txt2nid(cv->name)) == NID_undef) {\n            BIO_printf(bio_err,\n                       "%s:unknown object type in \'policy\' configuration\\n",\n                       cv->name);\n            goto end;\n        }\n        obj = OBJ_nid2obj(j);\n        last = -1;\n        for (;;) {\n            j = X509_NAME_get_index_by_OBJ(name, obj, last);\n            if (j < 0) {\n                if (last != -1)\n                    break;\n                tne = NULL;\n            } else {\n                tne = X509_NAME_get_entry(name, j);\n            }\n            last = j;\n            push = NULL;\n            if (strcmp(cv->value, "optional") == 0) {\n                if (tne != NULL)\n                    push = tne;\n            } else if (strcmp(cv->value, "supplied") == 0) {\n                if (tne == NULL) {\n                    BIO_printf(bio_err,\n                               "The %s field needed to be supplied and was missing\\n",\n                               cv->name);\n                    goto end;\n                } else\n                    push = tne;\n            } else if (strcmp(cv->value, "match") == 0) {\n                int last2;\n                if (tne == NULL) {\n                    BIO_printf(bio_err,\n                               "The mandatory %s field was missing\\n",\n                               cv->name);\n                    goto end;\n                }\n                last2 = -1;\n again2:\n                j = X509_NAME_get_index_by_OBJ(CAname, obj, last2);\n                if ((j < 0) && (last2 == -1)) {\n                    BIO_printf(bio_err,\n                               "The %s field does not exist in the CA certificate,\\nthe \'policy\' is misconfigured\\n",\n                               cv->name);\n                    goto end;\n                }\n                if (j >= 0) {\n                    push = X509_NAME_get_entry(CAname, j);\n                    str = X509_NAME_ENTRY_get_data(tne);\n                    str2 = X509_NAME_ENTRY_get_data(push);\n                    last2 = j;\n                    if (ASN1_STRING_cmp(str, str2) != 0)\n                        goto again2;\n                }\n                if (j < 0) {\n                    BIO_printf(bio_err,\n                               "The %s field needed to be the same in the\\nCA certificate (%s) and the request (%s)\\n",\n                               cv->name,\n                               ((str2 == NULL) ? "NULL" : (char *)str2->data),\n                               ((str == NULL) ? "NULL" : (char *)str->data));\n                    goto end;\n                }\n            } else {\n                BIO_printf(bio_err,\n                           "%s:invalid type in \'policy\' configuration\\n",\n                           cv->value);\n                goto end;\n            }\n            if (push != NULL) {\n                if (!X509_NAME_add_entry(subject, push, -1, 0)) {\n                    X509_NAME_ENTRY_free(push);\n                    BIO_printf(bio_err, "Memory allocation failure\\n");\n                    goto end;\n                }\n            }\n            if (j < 0)\n                break;\n        }\n    }\n    if (preserve) {\n        X509_NAME_free(subject);\n        subject = X509_NAME_dup(name);\n        if (subject == NULL)\n            goto end;\n    }\n    if (verbose)\n        BIO_printf(bio_err,\n                   "The subject name appears to be ok, checking data base for clashes\\n");\n    if (email_dn)\n        dn_subject = subject;\n    else {\n        X509_NAME_ENTRY *tmpne;\n        if ((dn_subject = X509_NAME_dup(subject)) == NULL) {\n            BIO_printf(bio_err, "Memory allocation failure\\n");\n            goto end;\n        }\n        while ((i = X509_NAME_get_index_by_NID(dn_subject,\n                                               NID_pkcs9_emailAddress,\n                                               -1)) >= 0) {\n            tmpne = X509_NAME_get_entry(dn_subject, i);\n            X509_NAME_delete_entry(dn_subject, i);\n            X509_NAME_ENTRY_free(tmpne);\n        }\n    }\n    if (BN_is_zero(serial))\n        row[DB_serial] = BUF_strdup("00");\n    else\n        row[DB_serial] = BN_bn2hex(serial);\n    if (row[DB_serial] == NULL) {\n        BIO_printf(bio_err, "Memory allocation failure\\n");\n        goto end;\n    }\n    if (db->attributes.unique_subject) {\n        OPENSSL_STRING *crow = row;\n        rrow = TXT_DB_get_by_index(db->db, DB_name, crow);\n        if (rrow != NULL) {\n            BIO_printf(bio_err,\n                       "ERROR:There is already a certificate for %s\\n",\n                       row[DB_name]);\n        }\n    }\n    if (rrow == NULL) {\n        rrow = TXT_DB_get_by_index(db->db, DB_serial, row);\n        if (rrow != NULL) {\n            BIO_printf(bio_err,\n                       "ERROR:Serial number %s has already been issued,\\n",\n                       row[DB_serial]);\n            BIO_printf(bio_err,\n                       "      check the database/serial_file for corruption\\n");\n        }\n    }\n    if (rrow != NULL) {\n        BIO_printf(bio_err, "The matching entry has the following details\\n");\n        if (rrow[DB_type][0] == \'E\')\n            p = "Expired";\n        else if (rrow[DB_type][0] == \'R\')\n            p = "Revoked";\n        else if (rrow[DB_type][0] == \'V\')\n            p = "Valid";\n        else\n            p = "\\ninvalid type, Data base error\\n";\n        BIO_printf(bio_err, "Type          :%s\\n", p);;\n        if (rrow[DB_type][0] == \'R\') {\n            p = rrow[DB_exp_date];\n            if (p == NULL)\n                p = "undef";\n            BIO_printf(bio_err, "Was revoked on:%s\\n", p);\n        }\n        p = rrow[DB_exp_date];\n        if (p == NULL)\n            p = "undef";\n        BIO_printf(bio_err, "Expires on    :%s\\n", p);\n        p = rrow[DB_serial];\n        if (p == NULL)\n            p = "undef";\n        BIO_printf(bio_err, "Serial Number :%s\\n", p);\n        p = rrow[DB_file];\n        if (p == NULL)\n            p = "undef";\n        BIO_printf(bio_err, "File name     :%s\\n", p);\n        p = rrow[DB_name];\n        if (p == NULL)\n            p = "undef";\n        BIO_printf(bio_err, "Subject Name  :%s\\n", p);\n        ok = -1;\n        goto end;\n    }\n    if (verbose)\n        BIO_printf(bio_err,\n                   "Everything appears to be ok, creating and signing the certificate\\n");\n    if ((ret = X509_new()) == NULL)\n        goto end;\n    ci = ret->cert_info;\n#ifdef X509_V3\n    if (!X509_set_version(ret, 2))\n        goto end;\n#endif\n    if (BN_to_ASN1_INTEGER(serial, ci->serialNumber) == NULL)\n        goto end;\n    if (selfsign) {\n        if (!X509_set_issuer_name(ret, subject))\n            goto end;\n    } else {\n        if (!X509_set_issuer_name(ret, X509_get_subject_name(x509)))\n            goto end;\n    }\n    if (strcmp(startdate, "today") == 0)\n        X509_gmtime_adj(X509_get_notBefore(ret), 0);\n    else\n        ASN1_TIME_set_string(X509_get_notBefore(ret), startdate);\n    if (enddate == NULL)\n        X509_time_adj_ex(X509_get_notAfter(ret), days, 0, NULL);\n    else {\n        int tdays;\n        ASN1_TIME_set_string(X509_get_notAfter(ret), enddate);\n        ASN1_TIME_diff(&tdays, NULL, NULL, X509_get_notAfter(ret));\n        days = tdays;\n    }\n    if (!X509_set_subject_name(ret, subject))\n        goto end;\n    pktmp = X509_REQ_get_pubkey(req);\n    i = X509_set_pubkey(ret, pktmp);\n    EVP_PKEY_free(pktmp);\n    if (!i)\n        goto end;\n    if (ext_sect) {\n        X509V3_CTX ctx;\n        if (ci->version == NULL)\n            if ((ci->version = ASN1_INTEGER_new()) == NULL)\n                goto end;\n        ASN1_INTEGER_set(ci->version, 2);\n        sk_X509_EXTENSION_pop_free(ci->extensions, X509_EXTENSION_free);\n        ci->extensions = NULL;\n        if (selfsign)\n            X509V3_set_ctx(&ctx, ret, ret, req, NULL, 0);\n        else\n            X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0);\n        if (extconf) {\n            if (verbose)\n                BIO_printf(bio_err, "Extra configuration file found\\n");\n            X509V3_set_nconf(&ctx, extconf);\n            if (!X509V3_EXT_add_nconf(extconf, &ctx, ext_sect, ret)) {\n                BIO_printf(bio_err,\n                           "ERROR: adding extensions in section %s\\n",\n                           ext_sect);\n                ERR_print_errors(bio_err);\n                goto end;\n            }\n            if (verbose)\n                BIO_printf(bio_err,\n                           "Successfully added extensions from file.\\n");\n        } else if (ext_sect) {\n            X509V3_set_nconf(&ctx, lconf);\n            if (!X509V3_EXT_add_nconf(lconf, &ctx, ext_sect, ret)) {\n                BIO_printf(bio_err,\n                           "ERROR: adding extensions in section %s\\n",\n                           ext_sect);\n                ERR_print_errors(bio_err);\n                goto end;\n            }\n            if (verbose)\n                BIO_printf(bio_err,\n                           "Successfully added extensions from config\\n");\n        }\n    }\n    if (!copy_extensions(ret, req, ext_copy)) {\n        BIO_printf(bio_err, "ERROR: adding extensions from request\\n");\n        ERR_print_errors(bio_err);\n        goto end;\n    }\n    if (email_dn == 0) {\n        if (!X509_set_subject_name(ret, dn_subject))\n            goto end;\n    }\n    if (!default_op) {\n        BIO_printf(bio_err, "Certificate Details:\\n");\n        certopt |= X509_FLAG_NO_SIGDUMP | X509_FLAG_NO_SIGNAME;\n        X509_print_ex(bio_err, ret, nameopt, certopt);\n    }\n    BIO_printf(bio_err, "Certificate is to be certified until ");\n    ASN1_TIME_print(bio_err, X509_get_notAfter(ret));\n    if (days)\n        BIO_printf(bio_err, " (%ld days)", days);\n    BIO_printf(bio_err, "\\n");\n    if (!batch) {\n        BIO_printf(bio_err, "Sign the certificate? [y/n]:");\n        (void)BIO_flush(bio_err);\n        buf[0] = \'\\0\';\n        if (!fgets(buf, sizeof(buf) - 1, stdin)) {\n            BIO_printf(bio_err,\n                       "CERTIFICATE WILL NOT BE CERTIFIED: I/O error\\n");\n            ok = 0;\n            goto end;\n        }\n        if (!((buf[0] == \'y\') || (buf[0] == \'Y\'))) {\n            BIO_printf(bio_err, "CERTIFICATE WILL NOT BE CERTIFIED\\n");\n            ok = 0;\n            goto end;\n        }\n    }\n    pktmp = X509_get_pubkey(ret);\n    if (EVP_PKEY_missing_parameters(pktmp) &&\n        !EVP_PKEY_missing_parameters(pkey))\n        EVP_PKEY_copy_parameters(pktmp, pkey);\n    EVP_PKEY_free(pktmp);\n    if (!do_X509_sign(ret, pkey, dgst, sigopts))\n        goto end;\n    row[DB_type] = app_malloc(2, "row db type");\n    tm = X509_get_notAfter(ret);\n    row[DB_exp_date] = app_malloc(tm->length + 1, "row expdate");\n    memcpy(row[DB_exp_date], tm->data, tm->length);\n    row[DB_exp_date][tm->length] = \'\\0\';\n    row[DB_rev_date] = NULL;\n    row[DB_file] = app_malloc(8, "row file");\n    row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);\n    if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||\n        (row[DB_file] == NULL) || (row[DB_name] == NULL)) {\n        BIO_printf(bio_err, "Memory allocation failure\\n");\n        goto end;\n    }\n    BUF_strlcpy(row[DB_file], "unknown", 8);\n    row[DB_type][0] = \'V\';\n    row[DB_type][1] = \'\\0\';\n    irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space");\n    for (i = 0; i < DB_NUMBER; i++) {\n        irow[i] = row[i];\n        row[i] = NULL;\n    }\n    irow[DB_NUMBER] = NULL;\n    if (!TXT_DB_insert(db->db, irow)) {\n        BIO_printf(bio_err, "failed to update database\\n");\n        BIO_printf(bio_err, "TXT_DB error number %ld\\n", db->db->error);\n        goto end;\n    }\n    ok = 1;\n end:\n    for (i = 0; i < DB_NUMBER; i++)\n        OPENSSL_free(row[i]);\n    X509_NAME_free(CAname);\n    X509_NAME_free(subject);\n    if (dn_subject != subject)\n        X509_NAME_free(dn_subject);\n    ASN1_UTCTIME_free(tmptm);\n    if (ok <= 0)\n        X509_free(ret);\n    else\n        *xret = ret;\n    return (ok);\n}', 'int X509_set_subject_name(X509 *x, X509_NAME *name)\n{\n    if ((x == NULL) || (x->cert_info == NULL))\n        return (0);\n    return (X509_NAME_set(&x->cert_info->subject, name));\n}', 'int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags,\n                  unsigned long cflag)\n{\n    long l;\n    int ret = 0, i;\n    char *m = NULL, mlch = \' \';\n    int nmindent = 0;\n    X509_CINF *ci;\n    ASN1_INTEGER *bs;\n    EVP_PKEY *pkey = NULL;\n    const char *neg;\n    if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {\n        mlch = \'\\n\';\n        nmindent = 12;\n    }\n    if (nmflags == X509_FLAG_COMPAT)\n        nmindent = 16;\n    ci = x->cert_info;\n    if (!(cflag & X509_FLAG_NO_HEADER)) {\n        if (BIO_write(bp, "Certificate:\\n", 13) <= 0)\n            goto err;\n        if (BIO_write(bp, "    Data:\\n", 10) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_VERSION)) {\n        l = X509_get_version(x);\n        if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\\n", "", l + 1, l) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_SERIAL)) {\n        if (BIO_write(bp, "        Serial Number:", 22) <= 0)\n            goto err;\n        bs = X509_get_serialNumber(x);\n        if (bs->length <= (int)sizeof(long)) {\n                ERR_set_mark();\n                l = ASN1_INTEGER_get(bs);\n                ERR_pop_to_mark();\n        } else {\n            l = -1;\n        }\n        if (l != -1) {\n            if (bs->type == V_ASN1_NEG_INTEGER) {\n                l = -l;\n                neg = "-";\n            } else\n                neg = "";\n            if (BIO_printf(bp, " %s%lu (%s0x%lx)\\n", neg, l, neg, l) <= 0)\n                goto err;\n        } else {\n            neg = (bs->type == V_ASN1_NEG_INTEGER) ? " (Negative)" : "";\n            if (BIO_printf(bp, "\\n%12s%s", "", neg) <= 0)\n                goto err;\n            for (i = 0; i < bs->length; i++) {\n                if (BIO_printf(bp, "%02x%c", bs->data[i],\n                               ((i + 1 == bs->length) ? \'\\n\' : \':\')) <= 0)\n                    goto err;\n            }\n        }\n    }\n    if (!(cflag & X509_FLAG_NO_SIGNAME)) {\n        if (X509_signature_print(bp, ci->signature, NULL) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_ISSUER)) {\n        if (BIO_printf(bp, "        Issuer:%c", mlch) <= 0)\n            goto err;\n        if (X509_NAME_print_ex(bp, X509_get_issuer_name(x), nmindent, nmflags)\n            < 0)\n            goto err;\n        if (BIO_write(bp, "\\n", 1) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_VALIDITY)) {\n        if (BIO_write(bp, "        Validity\\n", 17) <= 0)\n            goto err;\n        if (BIO_write(bp, "            Not Before: ", 24) <= 0)\n            goto err;\n        if (!ASN1_TIME_print(bp, X509_get_notBefore(x)))\n            goto err;\n        if (BIO_write(bp, "\\n            Not After : ", 25) <= 0)\n            goto err;\n        if (!ASN1_TIME_print(bp, X509_get_notAfter(x)))\n            goto err;\n        if (BIO_write(bp, "\\n", 1) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_SUBJECT)) {\n        if (BIO_printf(bp, "        Subject:%c", mlch) <= 0)\n            goto err;\n        if (X509_NAME_print_ex\n            (bp, X509_get_subject_name(x), nmindent, nmflags) < 0)\n            goto err;\n        if (BIO_write(bp, "\\n", 1) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_PUBKEY)) {\n        if (BIO_write(bp, "        Subject Public Key Info:\\n", 33) <= 0)\n            goto err;\n        if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0)\n            goto err;\n        if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0)\n            goto err;\n        if (BIO_puts(bp, "\\n") <= 0)\n            goto err;\n        pkey = X509_get_pubkey(x);\n        if (pkey == NULL) {\n            BIO_printf(bp, "%12sUnable to load Public Key\\n", "");\n            ERR_print_errors(bp);\n        } else {\n            EVP_PKEY_print_public(bp, pkey, 16, NULL);\n            EVP_PKEY_free(pkey);\n        }\n    }\n    if (!(cflag & X509_FLAG_NO_IDS)) {\n        if (ci->issuerUID) {\n            if (BIO_printf(bp, "%8sIssuer Unique ID: ", "") <= 0)\n                goto err;\n            if (!X509_signature_dump(bp, ci->issuerUID, 12))\n                goto err;\n        }\n        if (ci->subjectUID) {\n            if (BIO_printf(bp, "%8sSubject Unique ID: ", "") <= 0)\n                goto err;\n            if (!X509_signature_dump(bp, ci->subjectUID, 12))\n                goto err;\n        }\n    }\n    if (!(cflag & X509_FLAG_NO_EXTENSIONS))\n        X509V3_extensions_print(bp, "X509v3 extensions",\n                                ci->extensions, cflag, 8);\n    if (!(cflag & X509_FLAG_NO_SIGDUMP)) {\n        if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0)\n            goto err;\n    }\n    if (!(cflag & X509_FLAG_NO_AUX)) {\n        if (!X509_CERT_AUX_print(bp, x->aux, 0))\n            goto err;\n    }\n    ret = 1;\n err:\n    OPENSSL_free(m);\n    return (ret);\n}', 'int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)\n{\n    if (tm->type == V_ASN1_UTCTIME)\n        return ASN1_UTCTIME_print(bp, tm);\n    if (tm->type == V_ASN1_GENERALIZEDTIME)\n        return ASN1_GENERALIZEDTIME_print(bp, tm);\n    BIO_write(bp, "Bad time value", 14);\n    return (0);\n}', 'int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)\n{\n    char *v;\n    int gmt = 0;\n    int i;\n    int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;\n    char *f = NULL;\n    int f_len = 0;\n    i = tm->length;\n    v = (char *)tm->data;\n    if (i < 12)\n        goto err;\n    if (v[i - 1] == \'Z\')\n        gmt = 1;\n    for (i = 0; i < 12; i++)\n        if ((v[i] > \'9\') || (v[i] < \'0\'))\n            goto err;\n    y = (v[0] - \'0\') * 1000 + (v[1] - \'0\') * 100\n        + (v[2] - \'0\') * 10 + (v[3] - \'0\');\n    M = (v[4] - \'0\') * 10 + (v[5] - \'0\');\n    if ((M > 12) || (M < 1))\n        goto err;\n    d = (v[6] - \'0\') * 10 + (v[7] - \'0\');\n    h = (v[8] - \'0\') * 10 + (v[9] - \'0\');\n    m = (v[10] - \'0\') * 10 + (v[11] - \'0\');\n    if (tm->length >= 14 &&\n        (v[12] >= \'0\') && (v[12] <= \'9\') &&\n        (v[13] >= \'0\') && (v[13] <= \'9\')) {\n        s = (v[12] - \'0\') * 10 + (v[13] - \'0\');\n        if (tm->length >= 15 && v[14] == \'.\') {\n            int l = tm->length;\n            f = &v[14];\n            f_len = 1;\n            while (14 + f_len < l && f[f_len] >= \'0\' && f[f_len] <= \'9\')\n                ++f_len;\n        }\n    }\n    if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",\n                   mon[M - 1], d, h, m, s, f_len, f, y,\n                   (gmt) ? " GMT" : "") <= 0)\n        return (0);\n    else\n        return (1);\n err:\n    BIO_write(bp, "Bad time value", 14);\n    return (0);\n}']