summaryrefslogtreecommitdiffstats
path: root/apps/req.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-06-14 20:34:37 -0400
committerPauli <paul.dale@oracle.com>2017-07-05 11:32:35 +1000
commit0904e79a6e6109240d5a552f2699408b26cf63ee (patch)
treedf0b4928a751b05779164cf7dd84265407bea332 /apps/req.c
parentff281ee8369350d88e8b57af139614f5683e1e8c (diff)
Undo commit d420ac2
[extended tests] Original text: Use BUF_strlcpy() instead of strcpy(). Use BUF_strlcat() instead of strcat(). Use BIO_snprintf() instead of sprintf(). In some cases, keep better track of buffer lengths. This is part of a large change submitted by Markus Friedl <markus@openbsd.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/3701)
Diffstat (limited to 'apps/req.c')
-rw-r--r--apps/req.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/req.c b/apps/req.c
index 34d906566c..9b6c48d4c4 100644
--- a/apps/req.c
+++ b/apps/req.c
@@ -984,30 +984,30 @@ static int prompt_info(X509_REQ *req,
/* If OBJ not recognised ignore it */
if ((nid = OBJ_txt2nid(type)) == NID_undef)
goto start;
- if (BIO_snprintf(buf, sizeof buf, "%s_default", v->name)
- >= (int)sizeof(buf)) {
+ if (strlen(v->name) + sizeof("_default") > sizeof(buf)) {
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
return 0;
}
+ sprintf(buf, "%s_default", v->name);
if ((def = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
ERR_clear_error();
def = "";
}
- BIO_snprintf(buf, sizeof buf, "%s_value", v->name);
+ sprintf(buf, "%s_value", v->name);
if ((value = NCONF_get_string(req_conf, dn_sect, buf)) == NULL) {
ERR_clear_error();
value = NULL;
}
- BIO_snprintf(buf, sizeof buf, "%s_min", v->name);
+ sprintf(buf, "%s_min", v->name);
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_min)) {
ERR_clear_error();
n_min = -1;
}
- BIO_snprintf(buf, sizeof buf, "%s_max", v->name);
+ sprintf(buf, "%s_max", v->name);
if (!NCONF_get_number(req_conf, dn_sect, buf, &n_max)) {
ERR_clear_error();
n_max = -1;
@@ -1044,11 +1044,11 @@ static int prompt_info(X509_REQ *req,
if ((nid = OBJ_txt2nid(type)) == NID_undef)
goto start2;
- if (BIO_snprintf(buf, sizeof buf, "%s_default", type)
- >= (int)sizeof(buf)) {
+ if (strlen(type) + sizeof("_default") > sizeof(buf)) {
BIO_printf(bio_err, "Name '%s' too long\n", v->name);
return 0;
}
+ sprintf(buf, "%s_default", type);
if ((def = NCONF_get_string(req_conf, attr_sect, buf))
== NULL) {
@@ -1056,20 +1056,20 @@ static int prompt_info(X509_REQ *req,
def = "";
}
- BIO_snprintf(buf, sizeof buf, "%s_value", type);
+ sprintf(buf, "%s_value", type);
if ((value = NCONF_get_string(req_conf, attr_sect, buf))
== NULL) {
ERR_clear_error();
value = NULL;
}
- BIO_snprintf(buf, sizeof buf, "%s_min", type);
+ sprintf(buf, "%s_min", type);
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_min)) {
ERR_clear_error();
n_min = -1;
}
- BIO_snprintf(buf, sizeof buf, "%s_max", type);
+ sprintf(buf, "%s_max", type);
if (!NCONF_get_number(req_conf, attr_sect, buf, &n_max)) {
ERR_clear_error();
n_max = -1;
@@ -1168,8 +1168,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) {
- OPENSSL_strlcpy(buf, value, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ strcpy(buf, value);
+ strcat(buf, "\n");
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
@@ -1187,8 +1187,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def,
if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return 1;
- OPENSSL_strlcpy(buf, def, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ strcpy(buf, def);
+ strcat(buf, "\n");
} else if ((buf[0] == '.') && (buf[1] == '\n')) {
return 1;
}
@@ -1228,8 +1228,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) {
- OPENSSL_strlcpy(buf, value, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ strcpy(buf, value);
+ strcat(buf, "\n");
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
@@ -1247,8 +1247,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def,
if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return 1;
- OPENSSL_strlcpy(buf, def, sizeof buf);
- OPENSSL_strlcat(buf, "\n", sizeof buf);
+ strcpy(buf, def);
+ strcat(buf, "\n");
} else if ((buf[0] == '.') && (buf[1] == '\n')) {
return 1;
}