diff options
author | Rich Salz <rsalz@akamai.com> | 2015-12-16 22:12:24 +0100 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-12-16 22:14:49 +0100 |
commit | 7644a9aef8932ed4d1c3f25ed776c997702982be (patch) | |
tree | d8f1e7fca20ad12683a1e2e52c92b6999ada23a6 /apps | |
parent | fix for no-ec (diff) | |
download | openssl-7644a9aef8932ed4d1c3f25ed776c997702982be.tar.xz openssl-7644a9aef8932ed4d1c3f25ed776c997702982be.zip |
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: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/apps.c | 10 | ||||
-rw-r--r-- | apps/ca.c | 43 | ||||
-rw-r--r-- | apps/cms.c | 2 | ||||
-rw-r--r-- | apps/engine.c | 4 | ||||
-rw-r--r-- | apps/ocsp.c | 2 | ||||
-rw-r--r-- | apps/openssl.c | 2 | ||||
-rw-r--r-- | apps/passwd.c | 6 | ||||
-rw-r--r-- | apps/pkcs12.c | 4 | ||||
-rw-r--r-- | apps/rehash.c | 4 | ||||
-rw-r--r-- | apps/req.c | 18 | ||||
-rw-r--r-- | apps/s_server.c | 2 | ||||
-rw-r--r-- | apps/s_socket.c | 2 | ||||
-rw-r--r-- | apps/srp.c | 12 | ||||
-rw-r--r-- | apps/x509.c | 6 |
14 files changed, 50 insertions, 67 deletions
diff --git a/apps/apps.c b/apps/apps.c index c6b70d63a8..685536a434 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -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, ':'); @@ -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; diff --git a/apps/cms.c b/apps/cms.c index 14f8f55f2b..8cf99de516 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -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, diff --git a/apps/engine.c b/apps/engine.c index 17e6f789f7..c373df579c 100644 --- a/apps/engine.c +++ b/apps/engine.c @@ -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; } diff --git a/apps/ocsp.c b/apps/ocsp.c index ef7d62acd1..ceda592de9 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -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; diff --git a/apps/openssl.c b/apps/openssl.c index 592095e5f9..5ce04ceaf3 100644 --- a/apps/openssl.c +++ b/apps/openssl.c @@ -218,7 +218,7 @@ static char *make_config_name() char *p; if ((t = getenv("OPENSSL_CONF")) != NULL) - return BUF_strdup(t); + return OPENSSL_strdup(t); t = X509_get_default_cert_area(); len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1; diff --git a/apps/passwd.c b/apps/passwd.c index 2a32111e9d..f0ab243580 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -314,9 +314,9 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt) out_buf[0] = '$'; out_buf[1] = 0; assert(strlen(magic) <= 4); /* "1" or "apr1" */ - strncat(out_buf, magic, 4); - strncat(out_buf, "$", 1); - strncat(out_buf, salt, 8); + OPENSSL_strlcat(out_buf, magic, sizeof out_buf); + OPENSSL_strlcat(out_buf, "$", sizeof out_buf); + OPENSSL_strlcat(out_buf, salt, sizeof out_buf); assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */ salt_out = out_buf + 2 + strlen(magic); salt_len = strlen(salt_out); diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 11930e9e16..3d566f3df2 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -484,7 +484,7 @@ int pkcs12_main(int argc, char **argv) goto export_end; } if (!twopass) - BUF_strlcpy(macpass, pass, sizeof macpass); + OPENSSL_strlcpy(macpass, pass, sizeof macpass); p12 = PKCS12_create(cpass, name, key, ucert, certs, key_pbe, cert_pbe, iter, -1, keytype); @@ -542,7 +542,7 @@ int pkcs12_main(int argc, char **argv) } if (!twopass) - BUF_strlcpy(macpass, pass, sizeof macpass); + OPENSSL_strlcpy(macpass, pass, sizeof macpass); if ((options & INFO) && p12->mac) BIO_printf(bio_err, "MAC Iteration %ld\n", diff --git a/apps/rehash.c b/apps/rehash.c index e85265d1e6..38084a247f 100644 --- a/apps/rehash.c +++ b/apps/rehash.c @@ -175,7 +175,7 @@ static int add_entry(enum Type type, unsigned int hash, const char *filename, ep = app_malloc(sizeof(*ep), "collision bucket"); *ep = nilhentry; ep->old_id = ~0; - ep->filename = BUF_strdup(filename); + ep->filename = OPENSSL_strdup(filename); if (bp->last_entry) bp->last_entry->next = ep; if (bp->first_entry == NULL) @@ -468,7 +468,7 @@ int rehash_main(int argc, char **argv) while (*argv) errs += do_dir(*argv++, h); } else if ((env = getenv("SSL_CERT_DIR")) != NULL) { - m = BUF_strdup(env); + m = OPENSSL_strdup(env); for (e = strtok(m, ":"); e != NULL; e = strtok(NULL, ":")) errs += do_dir(e, h); OPENSSL_free(m); diff --git a/apps/req.c b/apps/req.c index c275763932..a0da788089 100644 --- a/apps/req.c +++ b/apps/req.c @@ -1189,8 +1189,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def, BIO_printf(bio_err, "%s [%s]:", text, def); (void)BIO_flush(bio_err); if (value != NULL) { - BUF_strlcpy(buf, value, sizeof buf); - BUF_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, value, sizeof buf); + OPENSSL_strlcat(buf, "\n", sizeof buf); BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; @@ -1208,8 +1208,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def, else if (buf[0] == '\n') { if ((def == NULL) || (def[0] == '\0')) return (1); - BUF_strlcpy(buf, def, sizeof buf); - BUF_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, def, sizeof buf); + OPENSSL_strlcat(buf, "\n", sizeof buf); } else if ((buf[0] == '.') && (buf[1] == '\n')) return (1); @@ -1248,8 +1248,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def, BIO_printf(bio_err, "%s [%s]:", text, def); (void)BIO_flush(bio_err); if (value != NULL) { - BUF_strlcpy(buf, value, sizeof buf); - BUF_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, value, sizeof buf); + OPENSSL_strlcat(buf, "\n", sizeof buf); BIO_printf(bio_err, "%s\n", value); } else { buf[0] = '\0'; @@ -1267,8 +1267,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def, else if (buf[0] == '\n') { if ((def == NULL) || (def[0] == '\0')) return (1); - BUF_strlcpy(buf, def, sizeof buf); - BUF_strlcat(buf, "\n", sizeof buf); + OPENSSL_strlcpy(buf, def, sizeof buf); + OPENSSL_strlcat(buf, "\n", sizeof buf); } else if ((buf[0] == '.') && (buf[1] == '\n')) return (1); @@ -1428,7 +1428,7 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr, return NULL; } EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &anam, ameth); - *palgnam = BUF_strdup(anam); + *palgnam = OPENSSL_strdup(anam); #ifndef OPENSSL_NO_ENGINE if (tmpeng) ENGINE_finish(tmpeng); diff --git a/apps/s_server.c b/apps/s_server.c index 698dd1c73b..84a640ef1a 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -3165,7 +3165,7 @@ static int add_session(SSL *ssl, SSL_SESSION *session) return 0; } - sess->id = BUF_memdup(SSL_SESSION_get_id(session, NULL), sess->idlen); + sess->id = OPENSSL_memdup(SSL_SESSION_get_id(session, NULL), sess->idlen); sess->der = app_malloc(sess->derlen, "get session buffer"); if (!sess->id) { BIO_printf(bio_err, "Out of memory adding to external cache\n"); diff --git a/apps/s_socket.c b/apps/s_socket.c index 9d1f04a6c5..75053e9591 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -560,7 +560,7 @@ static int do_accept(int acc_sock, int *sock, char **host) /* return(0); */ } else { *host = app_malloc(strlen(h1->h_name) + 1, "copy hostname"); - BUF_strlcpy(*host, h1->h_name, strlen(h1->h_name) + 1); + OPENSSL_strlcpy(*host, h1->h_name, strlen(h1->h_name) + 1); h2 = gethostbyname(*host); if (h2 == NULL) { diff --git a/apps/srp.c b/apps/srp.c index 24fb79887e..1c9a9bee43 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -486,9 +486,9 @@ int srp_main(int argc, char **argv) errors++; goto end; } - row[DB_srpid] = BUF_strdup(user); - row[DB_srptype] = BUF_strdup("v"); - row[DB_srpgN] = BUF_strdup(gNid); + row[DB_srpid] = OPENSSL_strdup(user); + row[DB_srptype] = OPENSSL_strdup("v"); + row[DB_srpgN] = OPENSSL_strdup(gNid); if ((row[DB_srpid] == NULL) || (row[DB_srpgN] == NULL) @@ -496,7 +496,7 @@ int srp_main(int argc, char **argv) || (row[DB_srpverifier] == NULL) || (row[DB_srpsalt] == NULL) || (userinfo - && ((row[DB_srpinfo] = BUF_strdup(userinfo)) == NULL)) + && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo)) == NULL)) || !update_index(db, row)) { OPENSSL_free(row[DB_srpid]); OPENSSL_free(row[DB_srpgN]); @@ -571,7 +571,7 @@ int srp_main(int argc, char **argv) } row[DB_srptype][0] = 'v'; - row[DB_srpgN] = BUF_strdup(gNid); + row[DB_srpgN] = OPENSSL_strdup(gNid); if (row[DB_srpid] == NULL || row[DB_srpgN] == NULL @@ -579,7 +579,7 @@ int srp_main(int argc, char **argv) || row[DB_srpverifier] == NULL || row[DB_srpsalt] == NULL || (userinfo - && ((row[DB_srpinfo] = BUF_strdup(userinfo)) + && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo)) == NULL))) goto end; diff --git a/apps/x509.c b/apps/x509.c index 1677ba5fda..283d0552af 100644 --- a/apps/x509.c +++ b/apps/x509.c @@ -949,15 +949,15 @@ static ASN1_INTEGER *x509_load_serial(char *CAfile, char *serialfile, : (strlen(serialfile))) + 1; buf = app_malloc(len, "serial# buffer"); if (serialfile == NULL) { - BUF_strlcpy(buf, CAfile, len); + OPENSSL_strlcpy(buf, CAfile, len); for (p = buf; *p; p++) if (*p == '.') { *p = '\0'; break; } - BUF_strlcat(buf, POSTFIX, len); + OPENSSL_strlcat(buf, POSTFIX, len); } else - BUF_strlcpy(buf, serialfile, len); + OPENSSL_strlcpy(buf, serialfile, len); serial = load_serial(buf, create, NULL); if (serial == NULL) |