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

remove malloc casts



Following ANSI C rules, remove the casts from calls to
OPENSSL_malloc and OPENSSL_realloc.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 3e47caff
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -180,7 +180,7 @@ int chopup_args(ARGS *arg, char *buf)
    arg->argc = 0;
    arg->argc = 0;
    if (arg->size == 0) {
    if (arg->size == 0) {
        arg->size = 20;
        arg->size = 20;
        arg->argv = (char **)OPENSSL_malloc(sizeof(char *) * arg->size);
        arg->argv = OPENSSL_malloc(sizeof(char *) * arg->size);
        if (arg->argv == NULL)
        if (arg->argv == NULL)
            return 0;
            return 0;
    }
    }
@@ -195,8 +195,7 @@ int chopup_args(ARGS *arg, char *buf)
        /* The start of something good :-) */
        /* The start of something good :-) */
        if (arg->argc >= arg->size) {
        if (arg->argc >= arg->size) {
            arg->size += 20;
            arg->size += 20;
            arg->argv = (char **)OPENSSL_realloc(arg->argv,
            arg->argv = OPENSSL_realloc(arg->argv, sizeof(char *) * arg->size);
                                                 sizeof(char *) * arg->size);
            if (arg->argv == NULL)
            if (arg->argv == NULL)
                return 0;
                return 0;
        }
        }
@@ -368,7 +367,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
            ok = UI_add_input_string(ui, prompt, ui_flags, buf,
            ok = UI_add_input_string(ui, prompt, ui_flags, buf,
                                     PW_MIN_LENGTH, bufsiz - 1);
                                     PW_MIN_LENGTH, bufsiz - 1);
        if (ok >= 0 && verify) {
        if (ok >= 0 && verify) {
            buff = (char *)OPENSSL_malloc(bufsiz);
            buff = OPENSSL_malloc(bufsiz);
            if (!buff) {
            if (!buff) {
                BIO_printf(bio_err, "Out of memory\n");
                BIO_printf(bio_err, "Out of memory\n");
                UI_free(ui);
                UI_free(ui);
+9 −12
Original line number Original line Diff line number Diff line
@@ -1986,17 +1986,17 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
        goto end;
        goto end;


    /* We now just add it to the database */
    /* We now just add it to the database */
    row[DB_type] = (char *)OPENSSL_malloc(2);
    row[DB_type] = OPENSSL_malloc(2);


    tm = X509_get_notAfter(ret);
    tm = X509_get_notAfter(ret);
    row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
    row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
    memcpy(row[DB_exp_date], tm->data, tm->length);
    memcpy(row[DB_exp_date], tm->data, tm->length);
    row[DB_exp_date][tm->length] = '\0';
    row[DB_exp_date][tm->length] = '\0';


    row[DB_rev_date] = NULL;
    row[DB_rev_date] = NULL;


    /* row[DB_serial] done already */
    /* row[DB_serial] done already */
    row[DB_file] = (char *)OPENSSL_malloc(8);
    row[DB_file] = OPENSSL_malloc(8);
    row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
    row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);


    if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
    if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
@@ -2008,8 +2008,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
    row[DB_type][0] = 'V';
    row[DB_type][0] = 'V';
    row[DB_type][1] = '\0';
    row[DB_type][1] = '\0';


    if ((irow =
    if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
         (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
        BIO_printf(bio_err, "Memory allocation failure\n");
        BIO_printf(bio_err, "Memory allocation failure\n");
        goto end;
        goto end;
    }
    }
@@ -2242,17 +2241,17 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
                   row[DB_serial], row[DB_name]);
                   row[DB_serial], row[DB_name]);


        /* We now just add it to the database */
        /* We now just add it to the database */
        row[DB_type] = (char *)OPENSSL_malloc(2);
        row[DB_type] = OPENSSL_malloc(2);


        tm = X509_get_notAfter(x509);
        tm = X509_get_notAfter(x509);
        row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
        row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
        memcpy(row[DB_exp_date], tm->data, tm->length);
        memcpy(row[DB_exp_date], tm->data, tm->length);
        row[DB_exp_date][tm->length] = '\0';
        row[DB_exp_date][tm->length] = '\0';


        row[DB_rev_date] = NULL;
        row[DB_rev_date] = NULL;


        /* row[DB_serial] done already */
        /* row[DB_serial] done already */
        row[DB_file] = (char *)OPENSSL_malloc(8);
        row[DB_file] = OPENSSL_malloc(8);


        /* row[DB_name] done already */
        /* row[DB_name] done already */


@@ -2265,9 +2264,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
        row[DB_type][0] = 'V';
        row[DB_type][0] = 'V';
        row[DB_type][1] = '\0';
        row[DB_type][1] = '\0';


        if ((irow =
        if ((irow = OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) == NULL) {
             (char **)OPENSSL_malloc(sizeof(char *) * (DB_NUMBER + 1))) ==
            NULL) {
            BIO_printf(bio_err, "Memory allocation failure\n");
            BIO_printf(bio_err, "Memory allocation failure\n");
            goto end;
            goto end;
        }
        }
@@ -2406,7 +2403,7 @@ static int do_updatedb(CA_DB *db)


    /* get actual time and make a string */
    /* get actual time and make a string */
    a_tm = X509_gmtime_adj(a_tm, 0);
    a_tm = X509_gmtime_adj(a_tm, 0);
    a_tm_s = (char *)OPENSSL_malloc(a_tm->length + 1);
    a_tm_s = OPENSSL_malloc(a_tm->length + 1);
    if (a_tm_s == NULL) {
    if (a_tm_s == NULL) {
        cnt = -1;
        cnt = -1;
        goto end;
        goto end;
+1 −1
Original line number Original line Diff line number Diff line
@@ -139,7 +139,7 @@ int dgst_main(int argc, char **argv)
    int engine_impl = 0;
    int engine_impl = 0;


    prog = opt_progname(argv[0]);
    prog = opt_progname(argv[0]);
    if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) {
    if ((buf = OPENSSL_malloc(BUFSIZE)) == NULL) {
        BIO_printf(bio_err, "%s: out of memory\n", prog);
        BIO_printf(bio_err, "%s: out of memory\n", prog);
        goto end;
        goto end;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -379,7 +379,7 @@ int dhparam_main(int argc, char **argv)


        len = BN_num_bytes(dh->p);
        len = BN_num_bytes(dh->p);
        bits = BN_num_bits(dh->p);
        bits = BN_num_bits(dh->p);
        data = (unsigned char *)OPENSSL_malloc(len);
        data = OPENSSL_malloc(len);
        if (data == NULL) {
        if (data == NULL) {
            perror("OPENSSL_malloc");
            perror("OPENSSL_malloc");
            goto end;
            goto end;
+1 −1
Original line number Original line Diff line number Diff line
@@ -273,7 +273,7 @@ int dsaparam_main(int argc, char **argv)


        len = BN_num_bytes(dsa->p);
        len = BN_num_bytes(dsa->p);
        bits_p = BN_num_bits(dsa->p);
        bits_p = BN_num_bits(dsa->p);
        data = (unsigned char *)OPENSSL_malloc(len + 20);
        data = OPENSSL_malloc(len + 20);
        if (data == NULL) {
        if (data == NULL) {
            perror("OPENSSL_malloc");
            perror("OPENSSL_malloc");
            goto end;
            goto end;
Loading