Commit 7644a9ae authored by Rich Salz's avatar Rich Salz Committed by Rich Salz
Browse files

Rename some BUF_xxx to OPENSSL_xxx



Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
Add #define's for the old names.
Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros.

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent e4cf8663
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -432,14 +432,14 @@ static char *app_get_pass(char *arg, int keepbio)
    int i;

    if (strncmp(arg, "pass:", 5) == 0)
        return BUF_strdup(arg + 5);
        return OPENSSL_strdup(arg + 5);
    if (strncmp(arg, "env:", 4) == 0) {
        tmp = getenv(arg + 4);
        if (!tmp) {
            BIO_printf(bio_err, "Can't read environment variable %s\n", arg + 4);
            return NULL;
        }
        return BUF_strdup(tmp);
        return OPENSSL_strdup(tmp);
    }
    if (!keepbio || !pwdbio) {
        if (strncmp(arg, "file:", 5) == 0) {
@@ -495,7 +495,7 @@ static char *app_get_pass(char *arg, int keepbio)
    tmp = strchr(tpass, '\n');
    if (tmp)
        *tmp = 0;
    return BUF_strdup(tpass);
    return OPENSSL_strdup(tpass);
}

static CONF *app_load_config_(BIO *in, const char *filename)
@@ -1444,7 +1444,7 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
    }

    if (suffix == NULL)
        BUF_strlcpy(buf[0], serialfile, BSIZE);
        OPENSSL_strlcpy(buf[0], serialfile, BSIZE);
    else {
#ifndef OPENSSL_SYS_VMS
        j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix);
@@ -1930,7 +1930,7 @@ int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value)
{
    int rv;
    char *stmp, *vtmp = NULL;
    stmp = BUF_strdup(value);
    stmp = OPENSSL_strdup(value);
    if (!stmp)
        return -1;
    vtmp = strchr(stmp, ':');
+13 −30
Original line number Diff line number Diff line
@@ -1067,7 +1067,7 @@ end_of_options:
            strcpy(buf[2], outdir);

#ifndef OPENSSL_SYS_VMS
            BUF_strlcat(buf[2], "/", sizeof(buf[2]));
            OPENSSL_strlcat(buf[2], "/", sizeof(buf[2]));
#endif

            n = (char *)&(buf[2][strlen(buf[2])]);
@@ -1679,7 +1679,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
    }

    if (BN_is_zero(serial))
        row[DB_serial] = BUF_strdup("00");
        row[DB_serial] = OPENSSL_strdup("00");
    else
        row[DB_serial] = BN_bn2hex(serial);
    if (row[DB_serial] == NULL) {
@@ -1898,17 +1898,13 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
        goto end;

    /* We now just add it to the database */
    row[DB_type] = app_malloc(2, "row db type");

    row[DB_type] = OPENSSL_strdup("V");
    tm = X509_get_notAfter(ret);
    row[DB_exp_date] = app_malloc(tm->length + 1, "row expdate");
    memcpy(row[DB_exp_date], tm->data, tm->length);
    row[DB_exp_date][tm->length] = '\0';

    row[DB_rev_date] = NULL;

    /* row[DB_serial] done already */
    row[DB_file] = app_malloc(8, "row file");
    row[DB_file] = OPENSSL_strdup("unknown");
    row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);

    if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
@@ -1916,9 +1912,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
        BIO_printf(bio_err, "Memory allocation failure\n");
        goto end;
    }
    BUF_strlcpy(row[DB_file], "unknown", 8);
    row[DB_type][0] = 'V';
    row[DB_type][1] = '\0';

    irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space");
    for (i = 0; i < DB_NUMBER; i++) {
@@ -2118,7 +2111,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
    if (!bn)
        goto end;
    if (BN_is_zero(bn))
        row[DB_serial] = BUF_strdup("00");
        row[DB_serial] = OPENSSL_strdup("00");
    else
        row[DB_serial] = BN_bn2hex(bn);
    BN_free(bn);
@@ -2137,23 +2130,13 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
                   row[DB_serial], row[DB_name]);

        /* We now just add it to the database */
        row[DB_type] = app_malloc(2, "row type");

        row[DB_type] = OPENSSL_strdup("V");
        tm = X509_get_notAfter(x509);
        row[DB_exp_date] = app_malloc(tm->length + 1, "row exp_data");
        memcpy(row[DB_exp_date], tm->data, tm->length);
        row[DB_exp_date][tm->length] = '\0';

        row[DB_rev_date] = NULL;

        /* row[DB_serial] done already */
        row[DB_file] = app_malloc(8, "row filename");

        /* row[DB_name] done already */

        BUF_strlcpy(row[DB_file], "unknown", 8);
        row[DB_type][0] = 'V';
        row[DB_type][1] = '\0';
        row[DB_file] = OPENSSL_strdup("unknown");

        irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row ptr");
        for (i = 0; i < DB_NUMBER; i++) {
@@ -2428,14 +2411,14 @@ char *make_revocation_str(int rev_type, char *rev_arg)
        i += strlen(other) + 1;

    str = app_malloc(i, "revocation reason");
    BUF_strlcpy(str, (char *)revtm->data, i);
    OPENSSL_strlcpy(str, (char *)revtm->data, i);
    if (reason) {
        BUF_strlcat(str, ",", i);
        BUF_strlcat(str, reason, i);
        OPENSSL_strlcat(str, ",", i);
        OPENSSL_strlcat(str, reason, i);
    }
    if (other) {
        BUF_strlcat(str, ",", i);
        BUF_strlcat(str, other, i);
        OPENSSL_strlcat(str, ",", i);
        OPENSSL_strlcat(str, other, i);
    }
    ASN1_UTCTIME_free(revtm);
    return str;
@@ -2553,7 +2536,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
    ASN1_OBJECT *hold = NULL;
    ASN1_GENERALIZEDTIME *comp_time = NULL;

    tmp = BUF_strdup(str);
    tmp = OPENSSL_strdup(str);
    if (!tmp) {
        BIO_printf(bio_err, "memory allocation failure\n");
        goto end;
+1 −1
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ int cms_main(int argc, char **argv)
            secret_keyid = NULL;
        }
        if (pwri_pass) {
            pwri_tmp = (unsigned char *)BUF_strdup((char *)pwri_pass);
            pwri_tmp = (unsigned char *)OPENSSL_strdup((char *)pwri_pass);
            if (!pwri_tmp)
                goto end;
            if (!CMS_add0_recipient_password(cms,
+2 −2
Original line number Diff line number Diff line
@@ -109,8 +109,8 @@ static int append_buf(char **buf, const char *s, int *size, int step)
        return 0;

    if (**buf != '\0')
        BUF_strlcat(*buf, ", ", *size);
    BUF_strlcat(*buf, s, *size);
        OPENSSL_strlcat(*buf, ", ", *size);
    OPENSSL_strlcat(*buf, s, *size);

    return 1;
}
+1 −1
Original line number Diff line number Diff line
@@ -1007,7 +1007,7 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
    OPENSSL_assert(bn);         /* FIXME: should report an error at this
                                 * point and abort */
    if (BN_is_zero(bn))
        itmp = BUF_strdup("00");
        itmp = OPENSSL_strdup("00");
    else
        itmp = BN_bn2hex(bn);
    row[DB_serial] = itmp;
Loading