summaryrefslogtreecommitdiffstats
path: root/apps/ca.c
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2016-05-09 18:42:58 +0200
committerRich Salz <rsalz@openssl.org>2016-07-20 01:35:38 -0400
commitf6c460e8f69e90fdb87129bb70951ced89c7906f (patch)
tree63966a5b1ea5339f1f81f19d0eae5f484c6987d7 /apps/ca.c
parentcdd202f2546f301d128a547d77b27fb4321d249b (diff)
Fix double calls to strlen
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1284)
Diffstat (limited to 'apps/ca.c')
-rw-r--r--apps/ca.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/apps/ca.c b/apps/ca.c
index 444e454df8..91006cf97c 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -2137,27 +2137,28 @@ static int get_certificate_status(const char *serial, CA_DB *db)
{
char *row[DB_NUMBER], **rrow;
int ok = -1, i;
+ size_t serial_len = strlen(serial);
/* Free Resources */
for (i = 0; i < DB_NUMBER; i++)
row[i] = NULL;
/* Malloc needed char spaces */
- row[DB_serial] = app_malloc(strlen(serial) + 2, "row serial#");
+ row[DB_serial] = app_malloc(serial_len + 2, "row serial#");
- if (strlen(serial) % 2) {
+ if (serial_len % 2) {
/*
* Set the first char to 0
*/ ;
row[DB_serial][0] = '0';
/* Copy String from serial to row[DB_serial] */
- memcpy(row[DB_serial] + 1, serial, strlen(serial));
- row[DB_serial][strlen(serial) + 1] = '\0';
+ memcpy(row[DB_serial] + 1, serial, serial_len);
+ row[DB_serial][serial_len + 1] = '\0';
} else {
/* Copy String from serial to row[DB_serial] */
- memcpy(row[DB_serial], serial, strlen(serial));
- row[DB_serial][strlen(serial)] = '\0';
+ memcpy(row[DB_serial], serial, serial_len);
+ row[DB_serial][serial_len] = '\0';
}
/* Make it Upper Case */