Commit 2234212c authored by Paul Yang's avatar Paul Yang Committed by Rich Salz
Browse files

Clean up a bundle of codingstyle stuff in apps directory



Mostly braces and NULL pointer check and also copyright year bump

Signed-off-by: default avatarPaul Yang <paulyang.inf@gmail.com>

Reviewed-by: default avatarKurt Roeckx <kurt@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3657)
parent 71d8c138
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
@@ -19,18 +19,19 @@ int app_RAND_load_file(const char *file, int dont_warn)
    int consider_randfile = (file == NULL);
    char buffer[200];

    if (file == NULL)
    if (file == NULL) {
        file = RAND_file_name(buffer, sizeof buffer);
#ifndef OPENSSL_NO_EGD
    else if (RAND_egd(file) > 0) {
    } else if (RAND_egd(file) > 0) {
        /*
         * we try if the given filename is an EGD socket. if it is, we don't
         * write anything back to the file.
         */
        egdsocket = 1;
        return 1;
    }
#endif
    }

    if (file == NULL || !RAND_load_file(file, -1)) {
        if (RAND_status() == 0) {
            if (!dont_warn) {
+72 −66
Original line number Diff line number Diff line
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
@@ -140,9 +140,8 @@ int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,

int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path)
{
    if (path == NULL) {
    if (path == NULL)
        return SSL_CTX_set_default_ctlog_list_file(ctx);
    }

    return SSL_CTX_set_ctlog_list_file(ctx, path);
}
@@ -312,8 +311,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
        if (ok >= 0)
            do {
                ok = UI_process(ui);
            }
            while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));
            } while (ok < 0 && UI_ctrl(ui, UI_CTRL_IS_REDOABLE, 0, 0, 0));

        OPENSSL_clear_free(buff, (unsigned int)bufsiz);

@@ -342,22 +340,24 @@ static char *app_get_pass(const char *arg, int keepbio);
int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2)
{
    int same;
    if (!arg2 || !arg1 || strcmp(arg1, arg2))
    if (arg2 == NULL || arg1 == NULL || strcmp(arg1, arg2))
        same = 0;
    else
        same = 1;
    if (arg1) {
    if (arg1 != NULL) {
        *pass1 = app_get_pass(arg1, same);
        if (!*pass1)
        if (*pass1 == NULL)
            return 0;
    } else if (pass1)
    } else if (pass1 != NULL) {
        *pass1 = NULL;
    if (arg2) {
    }
    if (arg2 != NULL) {
        *pass2 = app_get_pass(arg2, same ? 2 : 0);
        if (!*pass2)
        if (*pass2 == NULL)
            return 0;
    } else if (pass2)
    } else if (pass2 != NULL) {
        *pass2 = NULL;
    }
    return 1;
}

@@ -371,16 +371,16 @@ static char *app_get_pass(const char *arg, int keepbio)
        return OPENSSL_strdup(arg + 5);
    if (strncmp(arg, "env:", 4) == 0) {
        tmp = getenv(arg + 4);
        if (!tmp) {
        if (tmp == NULL) {
            BIO_printf(bio_err, "Can't read environment variable %s\n", arg + 4);
            return NULL;
        }
        return OPENSSL_strdup(tmp);
    }
    if (!keepbio || !pwdbio) {
    if (!keepbio || pwdbio == NULL) {
        if (strncmp(arg, "file:", 5) == 0) {
            pwdbio = BIO_new_file(arg + 5, "r");
            if (!pwdbio) {
            if (pwdbio == NULL) {
                BIO_printf(bio_err, "Can't open file %s\n", arg + 5);
                return NULL;
            }
@@ -429,7 +429,7 @@ static char *app_get_pass(const char *arg, int keepbio)
        return NULL;
    }
    tmp = strchr(tpass, '\n');
    if (tmp)
    if (tmp != NULL)
        *tmp = 0;
    return OPENSSL_strdup(tpass);
}
@@ -454,6 +454,7 @@ static CONF *app_load_config_(BIO *in, const char *filename)
    NCONF_free(conf);
    return NULL;
}

CONF *app_load_config(const char *filename)
{
    BIO *in;
@@ -467,6 +468,7 @@ CONF *app_load_config(const char *filename)
    BIO_free(in);
    return conf;
}

CONF *app_load_config_quiet(const char *filename)
{
    BIO *in;
@@ -540,9 +542,9 @@ static int load_pkcs12(BIO *in, const char *desc,
        goto die;
    }
    /* See if an empty password will do */
    if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0))
    if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0)) {
        pass = "";
    else {
    } else {
        if (!pem_cb)
            pem_cb = (pem_password_cb *)password_callback;
        len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data);
@@ -603,7 +605,6 @@ static int load_cert_crl_http(const char *url, X509 **pcert, X509_CRL **pcrl)
    OPENSSL_free(host);
    OPENSSL_free(path);
    OPENSSL_free(port);
    if (bio)
    BIO_free_all(bio);
    OCSP_REQ_CTX_free(rctx);
    if (rv != 1) {
@@ -630,17 +631,18 @@ X509 *load_cert(const char *file, int format, const char *cert_descrip)
    if (file == NULL) {
        unbuffer(stdin);
        cert = dup_bio_in(format);
    } else
    } else {
        cert = bio_open_default(file, 'r', format);
    }
    if (cert == NULL)
        goto end;

    if (format == FORMAT_ASN1)
    if (format == FORMAT_ASN1) {
        x = d2i_X509_bio(cert, NULL);
    else if (format == FORMAT_PEM)
    } else if (format == FORMAT_PEM) {
        x = PEM_read_bio_X509_AUX(cert, NULL,
                                  (pem_password_cb *)password_callback, NULL);
    else if (format == FORMAT_PKCS12) {
    } else if (format == FORMAT_PKCS12) {
        if (!load_pkcs12(cert, cert_descrip, NULL, NULL, NULL, &x, NULL))
            goto end;
    } else {
@@ -671,11 +673,11 @@ X509_CRL *load_crl(const char *infile, int format)
    in = bio_open_default(infile, 'r', format);
    if (in == NULL)
        goto end;
    if (format == FORMAT_ASN1)
    if (format == FORMAT_ASN1) {
        x = d2i_X509_CRL_bio(in, NULL);
    else if (format == FORMAT_PEM)
    } else if (format == FORMAT_PEM) {
        x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
    else {
    } else {
        BIO_printf(bio_err, "bad input format specified for input crl\n");
        goto end;
    }
@@ -705,9 +707,9 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
        goto end;
    }
    if (format == FORMAT_ENGINE) {
        if (e == NULL)
        if (e == NULL) {
            BIO_printf(bio_err, "no engine specified\n");
        else {
        } else {
#ifndef OPENSSL_NO_ENGINE
            if (ENGINE_init(e)) {
                pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
@@ -726,8 +728,9 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
    if (file == NULL && maybe_stdin) {
        unbuffer(stdin);
        key = dup_bio_in(format);
    } else
    } else {
        key = bio_open_default(file, 'r', format);
    }
    if (key == NULL)
        goto end;
    if (format == FORMAT_ASN1) {
@@ -736,21 +739,19 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
        pkey = PEM_read_bio_PrivateKey(key, NULL,
                                       (pem_password_cb *)password_callback,
                                       &cb_data);
    }
    else if (format == FORMAT_PKCS12) {
    } else if (format == FORMAT_PKCS12) {
        if (!load_pkcs12(key, key_descrip,
                         (pem_password_cb *)password_callback, &cb_data,
                         &pkey, NULL, NULL))
            goto end;
    }
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA) && !defined (OPENSSL_NO_RC4)
    else if (format == FORMAT_MSBLOB)
    } else if (format == FORMAT_MSBLOB) {
        pkey = b2i_PrivateKey_bio(key);
    else if (format == FORMAT_PVK)
    } else if (format == FORMAT_PVK) {
        pkey = b2i_PVK_bio(key, (pem_password_cb *)password_callback,
                           &cb_data);
#endif
    else {
    } else {
        BIO_printf(bio_err, "bad input format specified for key file\n");
        goto end;
    }
@@ -778,9 +779,9 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
        goto end;
    }
    if (format == FORMAT_ENGINE) {
        if (e == NULL)
        if (e == NULL) {
            BIO_printf(bio_err, "no engine specified\n");
        else {
        } else {
#ifndef OPENSSL_NO_ENGINE
            pkey = ENGINE_load_public_key(e, file, ui_method, &cb_data);
            if (pkey == NULL) {
@@ -796,14 +797,14 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
    if (file == NULL && maybe_stdin) {
        unbuffer(stdin);
        key = dup_bio_in(format);
    } else
    } else {
        key = bio_open_default(file, 'r', format);
    }
    if (key == NULL)
        goto end;
    if (format == FORMAT_ASN1) {
        pkey = d2i_PUBKEY_bio(key, NULL);
    }
    else if (format == FORMAT_ASN1RSA) {
    } else if (format == FORMAT_ASN1RSA) {
#ifndef OPENSSL_NO_RSA
        RSA *rsa;
        rsa = d2i_RSAPublicKey_bio(key, NULL);
@@ -833,16 +834,15 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
        BIO_printf(bio_err, "RSA keys not supported\n");
#endif
            pkey = NULL;
    }
    else if (format == FORMAT_PEM) {
    } else if (format == FORMAT_PEM) {
        pkey = PEM_read_bio_PUBKEY(key, NULL,
                                   (pem_password_cb *)password_callback,
                                   &cb_data);
    }
#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DSA)
    else if (format == FORMAT_MSBLOB)
    } else if (format == FORMAT_MSBLOB) {
        pkey = b2i_PublicKey_bio(key);
#endif
    }
 end:
    BIO_free(key);
    if (pkey == NULL)
@@ -880,36 +880,36 @@ static int load_certs_crls(const char *file, int format,

    BIO_free(bio);

    if (pcerts && *pcerts == NULL) {
    if (pcerts != NULL && *pcerts == NULL) {
        *pcerts = sk_X509_new_null();
        if (!*pcerts)
        if (*pcerts == NULL)
            goto end;
    }

    if (pcrls && *pcrls == NULL) {
    if (pcrls != NULL && *pcrls == NULL) {
        *pcrls = sk_X509_CRL_new_null();
        if (!*pcrls)
        if (*pcrls == NULL)
            goto end;
    }

    for (i = 0; i < sk_X509_INFO_num(xis); i++) {
        xi = sk_X509_INFO_value(xis, i);
        if (xi->x509 && pcerts) {
        if (xi->x509 != NULL && pcerts != NULL) {
            if (!sk_X509_push(*pcerts, xi->x509))
                goto end;
            xi->x509 = NULL;
        }
        if (xi->crl && pcrls) {
        if (xi->crl != NULL && pcrls != NULL) {
            if (!sk_X509_CRL_push(*pcrls, xi->crl))
                goto end;
            xi->crl = NULL;
        }
    }

    if (pcerts && sk_X509_num(*pcerts) > 0)
    if (pcerts != NULL && sk_X509_num(*pcerts) > 0)
        rv = 1;

    if (pcrls && sk_X509_CRL_num(*pcrls) > 0)
    if (pcrls != NULL && sk_X509_CRL_num(*pcrls) > 0)
        rv = 1;

 end:
@@ -917,11 +917,11 @@ static int load_certs_crls(const char *file, int format,
    sk_X509_INFO_pop_free(xis, X509_INFO_free);

    if (rv == 0) {
        if (pcerts) {
        if (pcerts != NULL) {
            sk_X509_pop_free(*pcerts, X509_free);
            *pcerts = NULL;
        }
        if (pcrls) {
        if (pcrls != NULL) {
            sk_X509_CRL_pop_free(*pcrls, X509_CRL_free);
            *pcrls = NULL;
        }
@@ -1126,8 +1126,9 @@ static int set_table_opts(unsigned long *flags, const char *arg,
    } else if (c == '+') {
        c = 1;
        arg++;
    } else
    } else {
        c = 1;
    }

    for (ptbl = in_tbl; ptbl->name; ptbl++) {
        if (strcasecmp(arg, ptbl->name) == 0) {
@@ -1172,9 +1173,9 @@ void print_bignum_var(BIO *out, const BIGNUM *in, const char *var,
                      int len, unsigned char *buffer)
{
    BIO_printf(out, "    static unsigned char %s_%d[] = {", var, len);
    if (BN_is_zero(in))
    if (BN_is_zero(in)) {
        BIO_printf(out, "\n\t0x00");
    else {
    } else {
        int i, l;

        l = BN_bn2bin(in, buffer);
@@ -1189,6 +1190,7 @@ void print_bignum_var(BIO *out, const BIGNUM *in, const char *var,
    }
    BIO_printf(out, "\n    };\n");
}

void print_array(BIO *out, const char* title, int len, const unsigned char* d)
{
    int i;
@@ -1222,9 +1224,10 @@ X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, i
                BIO_printf(bio_err, "Error loading file %s\n", CAfile);
                goto end;
            }
        } else
        } else {
            X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
        }
    }

    if (CApath != NULL || !noCApath) {
        lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
@@ -1235,9 +1238,10 @@ X509_STORE *setup_verify(const char *CAfile, const char *CApath, int noCAfile, i
                BIO_printf(bio_err, "Error loading directory %s\n", CApath);
                goto end;
            }
        } else
        } else {
            X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
        }
    }

    ERR_clear_error();
    return store;
@@ -1267,7 +1271,7 @@ ENGINE *setup_engine(const char *engine, int debug)
    ENGINE *e = NULL;

#ifndef OPENSSL_NO_ENGINE
    if (engine) {
    if (engine != NULL) {
        if (strcmp(engine, "auto") == 0) {
            BIO_printf(bio_err, "enabling auto ENGINE support\n");
            ENGINE_register_all_complete();
@@ -1873,9 +1877,10 @@ static void nodes_print(const char *name, STACK_OF(X509_POLICY_NODE) *nodes)
            node = sk_X509_POLICY_NODE_value(nodes, i);
            X509_POLICY_NODE_print(bio_err, node, 2);
        }
    } else
    } else {
        BIO_puts(bio_err, " <empty>\n");
    }
}

void policies_print(X509_STORE_CTX *ctx)
{
@@ -1919,9 +1924,10 @@ unsigned char *next_protos_parse(size_t *outlen, const char *in)
            }
            out[start] = i - start;
            start = i + 1;
        } else
        } else {
            out[i + 1] = in[i];
        }
    }

    *outlen = len + 1;
    return out;
@@ -2229,9 +2235,9 @@ double app_tminterval(int stop, int usertime)
    if (usertime)
        now = rus.tms_utime;

    if (stop == TM_START)
    if (stop == TM_START) {
        tmstart = now;
    else {
    } else {
        long int tck = sysconf(_SC_CLK_TCK);
        ret = (now - tmstart) / (double)tck;
    }
+7 −9
Original line number Diff line number Diff line
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
@@ -194,9 +194,7 @@ int asn1parse_main(int argc, char **argv)
                ERR_print_errors(bio_err);
                goto end;
            }
        }

        else {
        } else {

            if (informat == FORMAT_PEM) {
                BIO *tmp;
@@ -273,7 +271,7 @@ int asn1parse_main(int argc, char **argv)

    if ((length == 0) || ((long)length > num))
        length = (unsigned int)num;
    if (derout) {
    if (derout != NULL) {
        if (BIO_write(derout, str + offset, length) != (int)length) {
            BIO_printf(bio_err, "Error writing output\n");
            ERR_print_errors(bio_err);
@@ -323,12 +321,12 @@ static int do_generate(char *genstr, const char *genconf, BUF_MEM *buf)
    unsigned char *p;
    ASN1_TYPE *atyp = NULL;

    if (genconf) {
    if (genconf != NULL) {
        if ((cnf = app_load_config(genconf)) == NULL)
            goto err;
        if (!genstr)
        if (genstr == NULL)
            genstr = NCONF_get_string(cnf, "default", "asn1");
        if (!genstr) {
        if (genstr == NULL) {
            BIO_printf(bio_err, "Can't find 'asn1' in '%s'\n", genconf);
            goto err;
        }
@@ -338,7 +336,7 @@ static int do_generate(char *genstr, const char *genconf, BUF_MEM *buf)
    NCONF_free(cnf);
    cnf = NULL;

    if (!atyp)
    if (atyp == NULL)
        return -1;

    len = i2d_ASN1_TYPE(atyp, NULL);
+42 −38
Original line number Diff line number Diff line
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
@@ -471,17 +471,17 @@ end_of_options:
    app_RAND_load_file(randfile, 0);

    f = NCONF_get_string(conf, section, STRING_MASK);
    if (!f)
    if (f == NULL)
        ERR_clear_error();

    if (f && !ASN1_STRING_set_default_mask_asc(f)) {
    if (f != NULL && !ASN1_STRING_set_default_mask_asc(f)) {
        BIO_printf(bio_err, "Invalid global string mask setting %s\n", f);
        goto end;
    }

    if (chtype != MBSTRING_UTF8) {
        f = NCONF_get_string(conf, section, UTF8_IN);
        if (!f)
        if (f == NULL)
            ERR_clear_error();
        else if (strcmp(f, "yes") == 0)
            chtype = MBSTRING_UTF8;
@@ -489,9 +489,9 @@ end_of_options:

    db_attr.unique_subject = 1;
    p = NCONF_get_string(conf, section, ENV_UNIQUE_SUBJECT);
    if (p) {
    if (p != NULL)
        db_attr.unique_subject = parse_yesno(p, 1);
    } else
    else
        ERR_clear_error();

    /*****************************************************************/
@@ -520,7 +520,7 @@ end_of_options:
        && (keyfile = lookup_conf(conf, section, ENV_PRIVATE_KEY)) == NULL)
        goto end;

    if (!key) {
    if (key == NULL) {
        free_key = 1;
        if (!app_passwd(passinarg, NULL, &key, NULL)) {
            BIO_printf(bio_err, "Error getting password\n");
@@ -528,12 +528,11 @@ end_of_options:
        }
    }
    pkey = load_key(keyfile, keyformat, 0, key, e, "CA private key");
    if (key)
    if (key != NULL)
        OPENSSL_cleanse(key, strlen(key));
    if (pkey == NULL) {
    if (pkey == NULL)
        /* load_key() has already printed an appropriate message */
        goto end;
    }

    /*****************************************************************/
    /* we need a certificate */
@@ -568,7 +567,7 @@ end_of_options:

    f = NCONF_get_string(conf, section, ENV_NAMEOPT);

    if (f) {
    if (f != NULL) {
        if (!set_nameopt(f)) {
            BIO_printf(bio_err, "Invalid name options: \"%s\"\n", f);
            goto end;
@@ -578,24 +577,26 @@ end_of_options:

    f = NCONF_get_string(conf, section, ENV_CERTOPT);

    if (f) {
    if (f != NULL) {
        if (!set_cert_ex(&certopt, f)) {
            BIO_printf(bio_err, "Invalid certificate options: \"%s\"\n", f);
            goto end;
        }
        default_op = 0;
    } else
    } else {
        ERR_clear_error();
    }

    f = NCONF_get_string(conf, section, ENV_EXTCOPY);

    if (f) {
    if (f != NULL) {
        if (!set_ext_copy(&ext_copy, f)) {
            BIO_printf(bio_err, "Invalid extension copy option: \"%s\"\n", f);
            goto end;
        }
    } else
    } else {
        ERR_clear_error();
    }

    /*****************************************************************/
    /* lookup where to write new certificates */
@@ -774,17 +775,17 @@ end_of_options:
        if (serialfile == NULL)
            goto end;

        if (!extconf) {
        if (extconf == NULL) {
            /*
             * no '-extfile' option, so we look for extensions in the main
             * configuration file
             */
            if (!extensions) {
            if (extensions == NULL) {
                extensions = NCONF_get_string(conf, section, ENV_EXTENSIONS);
                if (!extensions)
                if (extensions == NULL)
                    ERR_clear_error();
            }
            if (extensions) {
            if (extensions != NULL) {
                /* Check syntax of file */
                X509V3_CTX ctx;
                X509V3_set_ctx_test(&ctx);
@@ -805,7 +806,7 @@ end_of_options:
            if (startdate == NULL)
                ERR_clear_error();
        }
        if (startdate && !ASN1_TIME_set_string_X509(NULL, startdate)) {
        if (startdate != NULL && !ASN1_TIME_set_string_X509(NULL, startdate)) {
            BIO_printf(bio_err,
                       "start date is invalid, it should be YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ\n");
            goto end;
@@ -818,7 +819,7 @@ end_of_options:
            if (enddate == NULL)
                ERR_clear_error();
        }
        if (enddate && !ASN1_TIME_set_string_X509(NULL, enddate)) {
        if (enddate != NULL && !ASN1_TIME_set_string_X509(NULL, enddate)) {
            BIO_printf(bio_err,
                       "end date is invalid, it should be YYMMDDHHMMSSZ or YYYYMMDDHHMMSSZ\n");
            goto end;
@@ -828,7 +829,7 @@ end_of_options:
            if (!NCONF_get_number(conf, section, ENV_DEFAULT_DAYS, &days))
                days = 0;
        }
        if (!enddate && (days == 0)) {
        if (enddate == NULL && (days == 0)) {
            BIO_printf(bio_err,
                       "cannot lookup how many days to certify for\n");
            goto end;
@@ -839,9 +840,9 @@ end_of_options:
            goto end;
        }
        if (verbose) {
            if (BN_is_zero(serial))
            if (BN_is_zero(serial)) {
                BIO_printf(bio_err, "next serial number is 00\n");
            else {
            } else {
                if ((f = BN_bn2hex(serial)) == NULL)
                    goto end;
                BIO_printf(bio_err, "next serial number is %s\n", f);
@@ -1045,12 +1046,12 @@ end_of_options:
    /*****************************************************************/
    if (gencrl) {
        int crl_v2 = 0;
        if (!crl_ext) {
        if (crl_ext == NULL) {
            crl_ext = NCONF_get_string(conf, section, ENV_CRLEXT);
            if (!crl_ext)
            if (crl_ext == NULL)
                ERR_clear_error();
        }
        if (crl_ext) {
        if (crl_ext != NULL) {
            /* Check syntax of file */
            X509V3_CTX ctx;
            X509V3_set_ctx_test(&ctx);
@@ -1141,12 +1142,12 @@ end_of_options:

        /* Add any extensions asked for */

        if (crl_ext || crlnumberfile != NULL) {
        if (crl_ext != NULL || crlnumberfile != NULL) {
            X509V3_CTX crlctx;
            X509V3_set_ctx(&crlctx, x509, NULL, NULL, crl, 0);
            X509V3_set_nconf(&crlctx, conf);

            if (crl_ext)
            if (crl_ext != NULL)
                if (!X509V3_EXT_CRL_add_nconf(conf, &crlctx, crl_ext, crl))
                    goto end;
            if (crlnumberfile != NULL) {
@@ -1160,7 +1161,7 @@ end_of_options:
                    goto end;
            }
        }
        if (crl_ext || crl_v2) {
        if (crl_ext != NULL || crl_v2) {
            if (!X509_CRL_set_version(crl, 1))
                goto end;       /* version 2 CRL */
        }
@@ -1297,8 +1298,9 @@ static int certify(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x509,
                   "Signature did not match the certificate request\n");
        ERR_print_errors(bio_err);
        goto end;
    } else
    } else {
        BIO_printf(bio_err, "Signature ok\n");
    }

    ok = do_body(xret, pkey, x509, dgst, sigopts, policy, db, serial, subj,
                 chtype, multirdn, email_dn, startdate, enddate, days, batch,
@@ -1346,8 +1348,9 @@ static int certify_cert(X509 **xret, const char *infile, EVP_PKEY *pkey, X509 *x
        ok = 0;
        BIO_printf(bio_err, "Signature did not match the certificate\n");
        goto end;
    } else
    } else {
        BIO_printf(bio_err, "Signature ok\n");
    }

    if ((rreq = X509_to_X509_REQ(req, NULL, NULL)) == NULL)
        goto end;
@@ -1502,8 +1505,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
                               "The %s field needed to be supplied and was missing\n",
                               cv->name);
                    goto end;
                } else
                } else {
                    push = tne;
                }
            } else if (strcmp(cv->value, "match") == 0) {
                int last2;

@@ -1578,9 +1582,9 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
     * And add it later on because of the method extensions are added (altName)
     */

    if (email_dn)
    if (email_dn) {
        dn_subject = subject;
    else {
    } else {
        X509_NAME_ENTRY *tmpne;
        /*
         * Its best to dup the subject DN and then delete any email addresses
@@ -1718,7 +1722,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
        else
            X509V3_set_ctx(&ctx, x509, ret, req, NULL, 0);

        if (extconf) {
        if (extconf != NULL) {
            if (verbose)
                BIO_printf(bio_err, "Extra configuration file found\n");

@@ -2505,9 +2509,9 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
            goto end;
        }

        if (reason_code == 7)
        if (reason_code == 7) {
            reason_code = OCSP_REVOKED_STATUS_REMOVEFROMCRL;
        else if (reason_code == 8) { /* Hold instruction */
        } else if (reason_code == 8) { /* Hold instruction */
            if (!arg_str) {
                BIO_printf(bio_err, "missing hold instruction\n");
                goto end;
+1 −1
Original line number Diff line number Diff line
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
Loading