Commit ecf3a1fb authored by Rich Salz's avatar Rich Salz
Browse files

Remove needless bio_err argument



Many functions had a BIO* parameter, and it was always called
with bio_err.  Remove the param and just use bio_err.

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent bea6cd3e
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -2006,34 +2006,34 @@ int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value)
    return rv;
}

static void nodes_print(BIO *out, const char *name,
                        STACK_OF(X509_POLICY_NODE) *nodes)
static void nodes_print(const char *name, STACK_OF(X509_POLICY_NODE) *nodes)
{
    X509_POLICY_NODE *node;
    int i;
    BIO_printf(out, "%s Policies:", name);

    BIO_printf(bio_err, "%s Policies:", name);
    if (nodes) {
        BIO_puts(out, "\n");
        BIO_puts(bio_err, "\n");
        for (i = 0; i < sk_X509_POLICY_NODE_num(nodes); i++) {
            node = sk_X509_POLICY_NODE_value(nodes, i);
            X509_POLICY_NODE_print(out, node, 2);
            X509_POLICY_NODE_print(bio_err, node, 2);
        }
    } else
        BIO_puts(out, " <empty>\n");
        BIO_puts(bio_err, " <empty>\n");
}

void policies_print(BIO *out, X509_STORE_CTX *ctx)
void policies_print(X509_STORE_CTX *ctx)
{
    X509_POLICY_TREE *tree;
    int explicit_policy;
    tree = X509_STORE_CTX_get0_policy_tree(ctx);
    explicit_policy = X509_STORE_CTX_get_explicit_policy(ctx);

    BIO_printf(out, "Require explicit Policy: %s\n",
    BIO_printf(bio_err, "Require explicit Policy: %s\n",
               explicit_policy ? "True" : "False");

    nodes_print(out, "Authority", X509_policy_tree_get0_policies(tree));
    nodes_print(out, "User", X509_policy_tree_get0_user_policies(tree));
    nodes_print("Authority", X509_policy_tree_get0_policies(tree));
    nodes_print("User", X509_policy_tree_get0_user_policies(tree));
}

#if !defined(OPENSSL_NO_JPAKE) && !defined(OPENSSL_NO_PSK)
+1 −1
Original line number Diff line number Diff line
@@ -489,7 +489,7 @@ int parse_yesno(const char *str, int def);
X509_NAME *parse_name(char *str, long chtype, int multirdn);
int args_verify(char ***pargs, int *pargc,
                int *badarg, X509_VERIFY_PARAM **pm);
void policies_print(BIO *out, X509_STORE_CTX *ctx);
void policies_print(X509_STORE_CTX *ctx);
int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value);
int init_gen_str(EVP_PKEY_CTX **pctx,
+6 −6
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ OPTIONS asn1parse_options[] = {
    {NULL}
};

static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf);
static int do_generate(char *genstr, char *genconf, BUF_MEM *buf);

int asn1parse_main(int argc, char **argv)
{
@@ -215,7 +215,7 @@ int asn1parse_main(int argc, char **argv)
            goto end;           /* Pre-allocate :-) */

        if (genstr || genconf) {
            num = do_generate(bio_err, genstr, genconf, buf);
            num = do_generate(genstr, genconf, buf);
            if (num < 0) {
                ERR_print_errors(bio_err);
                goto end;
@@ -335,7 +335,7 @@ int asn1parse_main(int argc, char **argv)
    return (ret);
}

static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
static int do_generate(char *genstr, char *genconf, BUF_MEM *buf)
{
    CONF *cnf = NULL;
    int len;
@@ -350,7 +350,7 @@ static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
        if (!genstr)
            genstr = NCONF_get_string(cnf, "default", "asn1");
        if (!genstr) {
            BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
            BIO_printf(bio_err, "Can't find 'asn1' in '%s'\n", genconf);
            goto err;
        }
    }
@@ -380,10 +380,10 @@ static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
 conferr:

    if (errline > 0)
        BIO_printf(bio, "Error on line %ld of config file '%s'\n",
        BIO_printf(bio_err, "Error on line %ld of config file '%s'\n",
                   errline, genconf);
    else
        BIO_printf(bio, "Error loading config file '%s'\n", genconf);
        BIO_printf(bio_err, "Error loading config file '%s'\n", genconf);

 err:
    NCONF_free(cnf);
+15 −15
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ static int do_updatedb(CA_DB *db);
static int check_time_format(const char *str);
char *make_revocation_str(int rev_type, char *rev_arg);
int make_revoked(X509_REVOKED *rev, const char *str);
int old_entry_print(BIO *bp, ASN1_OBJECT *obj, ASN1_STRING *str);
static int old_entry_print(ASN1_OBJECT *obj, ASN1_STRING *str);

static CONF *conf = NULL;
static CONF *extconf = NULL;
@@ -1604,7 +1604,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
        }

        if (default_op)
            old_entry_print(bio_err, obj, str);
            old_entry_print(obj, str);
    }

    /* Ok, now we check the 'policy' stuff. */
@@ -2632,42 +2632,42 @@ int make_revoked(X509_REVOKED *rev, const char *str)
    return ret;
}

int old_entry_print(BIO *bp, ASN1_OBJECT *obj, ASN1_STRING *str)
static int old_entry_print(ASN1_OBJECT *obj, ASN1_STRING *str)
{
    char buf[25], *pbuf, *p;
    int j;
    j = i2a_ASN1_OBJECT(bp, obj);
    j = i2a_ASN1_OBJECT(bio_err, obj);
    pbuf = buf;
    for (j = 22 - j; j > 0; j--)
        *(pbuf++) = ' ';
    *(pbuf++) = ':';
    *(pbuf++) = '\0';
    BIO_puts(bp, buf);
    BIO_puts(bio_err, buf);

    if (str->type == V_ASN1_PRINTABLESTRING)
        BIO_printf(bp, "PRINTABLE:'");
        BIO_printf(bio_err, "PRINTABLE:'");
    else if (str->type == V_ASN1_T61STRING)
        BIO_printf(bp, "T61STRING:'");
        BIO_printf(bio_err, "T61STRING:'");
    else if (str->type == V_ASN1_IA5STRING)
        BIO_printf(bp, "IA5STRING:'");
        BIO_printf(bio_err, "IA5STRING:'");
    else if (str->type == V_ASN1_UNIVERSALSTRING)
        BIO_printf(bp, "UNIVERSALSTRING:'");
        BIO_printf(bio_err, "UNIVERSALSTRING:'");
    else
        BIO_printf(bp, "ASN.1 %2d:'", str->type);
        BIO_printf(bio_err, "ASN.1 %2d:'", str->type);

    p = (char *)str->data;
    for (j = str->length; j > 0; j--) {
        if ((*p >= ' ') && (*p <= '~'))
            BIO_printf(bp, "%c", *p);
            BIO_printf(bio_err, "%c", *p);
        else if (*p & 0x80)
            BIO_printf(bp, "\\0x%02X", *p);
            BIO_printf(bio_err, "\\0x%02X", *p);
        else if ((unsigned char)*p == 0xf7)
            BIO_printf(bp, "^?");
            BIO_printf(bio_err, "^?");
        else
            BIO_printf(bp, "^%c", *p + '@');
            BIO_printf(bio_err, "^%c", *p + '@');
        p++;
    }
    BIO_printf(bp, "'\n");
    BIO_printf(bio_err, "'\n");
    return 1;
}

+19 −19
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@

static int save_certs(char *signerfile, STACK_OF(X509) *signers);
static int cms_cb(int ok, X509_STORE_CTX *ctx);
static void receipt_request_print(BIO *out, CMS_ContentInfo *cms);
static void receipt_request_print(CMS_ContentInfo *cms);
static CMS_ReceiptRequest *make_receipt_request(STACK_OF(OPENSSL_STRING)
                                                *rr_to, int rr_allorfirst, STACK_OF(OPENSSL_STRING)
                                                *rr_from);
@@ -1075,7 +1075,7 @@ int cms_main(int argc, char **argv)
            sk_X509_free(signers);
        }
        if (rr_print)
            receipt_request_print(bio_err, cms);
            receipt_request_print(cms);

    } else if (operation == SMIME_VERIFY_RECEIPT) {
        if (CMS_verify_receipt(rcms, cms, other, store, flags) > 0)
@@ -1190,31 +1190,31 @@ static int cms_cb(int ok, X509_STORE_CTX *ctx)
        && ((error != X509_V_OK) || (ok != 2)))
        return ok;

    /* Should be bio_err? */
    policies_print(bio_out, ctx);
    policies_print(ctx);

    return ok;

}

static void gnames_stack_print(BIO *out, STACK_OF(GENERAL_NAMES) *gns)
static void gnames_stack_print(STACK_OF(GENERAL_NAMES) *gns)
{
    STACK_OF(GENERAL_NAME) *gens;
    GENERAL_NAME *gen;
    int i, j;

    for (i = 0; i < sk_GENERAL_NAMES_num(gns); i++) {
        gens = sk_GENERAL_NAMES_value(gns, i);
        for (j = 0; j < sk_GENERAL_NAME_num(gens); j++) {
            gen = sk_GENERAL_NAME_value(gens, j);
            BIO_puts(out, "    ");
            GENERAL_NAME_print(out, gen);
            BIO_puts(out, "\n");
            BIO_puts(bio_err, "    ");
            GENERAL_NAME_print(bio_err, gen);
            BIO_puts(bio_err, "\n");
        }
    }
    return;
}

static void receipt_request_print(BIO *out, CMS_ContentInfo *cms)
static void receipt_request_print(CMS_ContentInfo *cms)
{
    STACK_OF(CMS_SignerInfo) *sis;
    CMS_SignerInfo *si;
@@ -1238,22 +1238,22 @@ static void receipt_request_print(BIO *out, CMS_ContentInfo *cms)
            int idlen;
            CMS_ReceiptRequest_get0_values(rr, &scid, &allorfirst,
                                           &rlist, &rto);
            BIO_puts(out, "  Signed Content ID:\n");
            BIO_puts(bio_err, "  Signed Content ID:\n");
            idlen = ASN1_STRING_length(scid);
            id = (char *)ASN1_STRING_data(scid);
            BIO_dump_indent(out, id, idlen, 4);
            BIO_puts(out, "  Receipts From");
            BIO_dump_indent(bio_err, id, idlen, 4);
            BIO_puts(bio_err, "  Receipts From");
            if (rlist) {
                BIO_puts(out, " List:\n");
                gnames_stack_print(out, rlist);
                BIO_puts(bio_err, " List:\n");
                gnames_stack_print(rlist);
            } else if (allorfirst == 1)
                BIO_puts(out, ": First Tier\n");
                BIO_puts(bio_err, ": First Tier\n");
            else if (allorfirst == 0)
                BIO_puts(out, ": All\n");
                BIO_puts(bio_err, ": All\n");
            else
                BIO_printf(out, " Unknown (%d)\n", allorfirst);
            BIO_puts(out, "  Receipts To:\n");
            gnames_stack_print(out, rto);
                BIO_printf(bio_err, " Unknown (%d)\n", allorfirst);
            BIO_puts(bio_err, "  Receipts To:\n");
            gnames_stack_print(rto);
        }
        if (rr)
            CMS_ReceiptRequest_free(rr);
Loading