-/* $OpenBSD: ca.c,v 1.39 2021/08/28 04:02:20 inoguchi Exp $ */
+/* $OpenBSD: ca.c,v 1.40 2021/08/28 05:14:30 inoguchi Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
row[DB_type] = malloc(2);
tm = X509_get_notAfter(ret);
- row[DB_exp_date] = malloc(tm->length + 1);
+ row[DB_exp_date] = strndup(tm->data, tm->length);
if (row[DB_type] == NULL || row[DB_exp_date] == NULL) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto err;
}
- 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_type] = malloc(2);
tm = X509_get_notAfter(x509);
- row[DB_exp_date] = malloc(tm->length + 1);
+ row[DB_exp_date] = strndup(tm->data, tm->length);
if (row[DB_type] == NULL || row[DB_exp_date] == NULL) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto err;
}
- memcpy(row[DB_exp_date], tm->data, tm->length);
- row[DB_exp_date][tm->length] = '\0';
row[DB_rev_date] = NULL;
cnt = -1;
goto err;
}
- a_tm_s = malloc(a_tm->length + 1);
+ a_tm_s = strndup(a_tm->data, a_tm->length);
if (a_tm_s == NULL) {
cnt = -1;
goto err;
}
- memcpy(a_tm_s, a_tm->data, a_tm->length);
- a_tm_s[a_tm->length] = '\0';
if (strncmp(a_tm_s, "49", 2) <= 0)
a_y2k = 1;