Commit 96487cdd authored by Matt Caswell's avatar Matt Caswell
Browse files

Continue standardisation of malloc handling in apps



continue on from previous commits but in the apps directory

Reviewed-by: default avatarKurt Roeckx <kurt@openssl.org>
parent 90945fa3
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -646,7 +646,7 @@ int load_cert_crl_http(const char *url, X509 **pcert, X509_CRL **pcrl)
    if (!bio || !BIO_set_conn_port(bio, port))
        goto err;
    rctx = OCSP_REQ_CTX_new(bio, 1024);
    if (!rctx)
    if (rctx == NULL)
        goto err;
    if (!OCSP_REQ_CTX_http(rctx, "GET", path))
        goto err;
@@ -856,7 +856,7 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
        rsa = d2i_RSAPublicKey_bio(key, NULL);
        if (rsa) {
            pkey = EVP_PKEY_new();
            if (pkey)
            if (pkey != NULL)
                EVP_PKEY_set1_RSA(pkey, rsa);
            RSA_free(rsa);
        } else
@@ -866,9 +866,9 @@ EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
        rsa = PEM_read_bio_RSAPublicKey(key, NULL,
                                        (pem_password_cb *)password_callback,
                                        &cb_data);
        if (rsa) {
        if (rsa != NULL) {
            pkey = EVP_PKEY_new();
            if (pkey)
            if (pkey != NULL)
                EVP_PKEY_set1_RSA(pkey, rsa);
            RSA_free(rsa);
        } else
@@ -1252,7 +1252,7 @@ X509_STORE *setup_verify(char *CAfile, char *CApath, int noCAfile, int noCApath)
    X509_STORE *store = X509_STORE_new();
    X509_LOOKUP *lookup;

    if (!store)
    if (store == NULL)
        goto end;

    if(CAfile != NULL || !noCAfile) {
@@ -1541,7 +1541,7 @@ int rand_serial(BIGNUM *b, ASN1_INTEGER *ai)
    else
        btmp = BN_new();

    if (!btmp)
    if (btmp == NULL)
        return 0;

    if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))
@@ -1901,7 +1901,7 @@ int bio_to_mem(unsigned char **out, int maxlen, BIO *in)
    int len, ret;
    unsigned char tbuf[1024];
    mem = BIO_new(BIO_s_mem());
    if (!mem)
    if (mem == NULL)
        return -1;
    for (;;) {
        if ((maxlen != -1) && maxlen < 1024)
+7 −5
Original line number Diff line number Diff line
@@ -1165,7 +1165,7 @@ end_of_options:
            goto end;

        tmptm = ASN1_TIME_new();
        if (!tmptm)
        if (tmptm == NULL)
            goto end;
        X509_gmtime_adj(tmptm, 0);
        X509_CRL_set_lastUpdate(crl, tmptm);
@@ -2283,10 +2283,12 @@ static int do_updatedb(CA_DB *db)
    char **rrow, *a_tm_s;

    a_tm = ASN1_UTCTIME_new();
    if (a_tm == NULL)
        return -1;

    /* get actual time and make a string */
    a_tm = X509_gmtime_adj(a_tm, 0);
    a_tm_s = (char *)OPENSSL_malloc(a_tm->length + 1);
    a_tm_s = (char *)app_malloc(a_tm->length + 1, "time string");

    memcpy(a_tm_s, a_tm->data, a_tm->length);
    a_tm_s[a_tm->length] = '\0';
@@ -2470,7 +2472,7 @@ int make_revoked(X509_REVOKED *rev, const char *str)

    if (rev && (reason_code != OCSP_REVOKED_STATUS_NOSTATUS)) {
        rtmp = ASN1_ENUMERATED_new();
        if (!rtmp || !ASN1_ENUMERATED_set(rtmp, reason_code))
        if (rtmp == NULL || !ASN1_ENUMERATED_set(rtmp, reason_code))
            goto end;
        if (!X509_REVOKED_add1_ext_i2d(rev, NID_crl_reason, rtmp, 0, 0))
            goto end;
@@ -2576,7 +2578,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,

    if (prevtm) {
        *prevtm = ASN1_UTCTIME_new();
        if (!*prevtm) {
        if (*prevtm == NULL) {
            BIO_printf(bio_err, "memory allocation failure\n");
            goto end;
        }
@@ -2622,7 +2624,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
                goto end;
            }
            comp_time = ASN1_GENERALIZEDTIME_new();
            if (!comp_time) {
            if (comp_time == NULL) {
                BIO_printf(bio_err, "memory allocation failure\n");
                goto end;
            }
+1 −1
Original line number Diff line number Diff line
@@ -1269,7 +1269,7 @@ static STACK_OF(GENERAL_NAMES) *make_names_stack(STACK_OF(OPENSSL_STRING) *ns)
        if (!gen)
            goto err;
        gens = GENERAL_NAMES_new();
        if (!gens)
        if (gens == NULL)
            goto err;
        if (!sk_GENERAL_NAME_push(gens, gen))
            goto err;
+3 −3
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ int dhparam_main(int argc, char **argv)

        BN_GENCB *cb;
        cb = BN_GENCB_new();
        if (!cb) {
        if (cb == NULL) {
            ERR_print_errors(bio_err);
            goto end;
        }
@@ -271,7 +271,7 @@ int dhparam_main(int argc, char **argv)

            BIO_printf(bio_err,
                       "Generating DSA parameters, %d bit long prime\n", num);
            if (!dsa
            if (dsa == NULL
                || !DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL,
                                               cb)) {
                DSA_free(dsa);
@@ -295,7 +295,7 @@ int dhparam_main(int argc, char **argv)
                       "Generating DH parameters, %d bit long safe prime, generator %d\n",
                       num, g);
            BIO_printf(bio_err, "This is going to take a long time\n");
            if (!dh || !DH_generate_parameters_ex(dh, num, g, cb)) {
            if (dh == NULL || !DH_generate_parameters_ex(dh, num, g, cb)) {
                BN_GENCB_free(cb);
                ERR_print_errors(bio_err);
                goto end;
+2 −2
Original line number Diff line number Diff line
@@ -208,14 +208,14 @@ int dsaparam_main(int argc, char **argv)

    if (numbits > 0) {
        cb = BN_GENCB_new();
        if (!cb) {
        if (cb == NULL) {
            BIO_printf(bio_err, "Error allocating BN_GENCB object\n");
            goto end;
        }
        BN_GENCB_set(cb, dsa_cb, bio_err);
        assert(need_rand);
        dsa = DSA_new();
        if (!dsa) {
        if (dsa == NULL) {
            BIO_printf(bio_err, "Error allocating DSA object\n");
            goto end;
        }
Loading