-/* $OpenBSD: ca.c,v 1.20 2015/12/24 16:54:37 mmcc Exp $ */
+/* $OpenBSD: ca.c,v 1.21 2016/08/30 11:32:28 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
STACK_OF(CONF_VALUE) * attribs = NULL;
STACK_OF(X509) * cert_sk = NULL;
STACK_OF(OPENSSL_STRING) * sigopts = NULL;
-#define BUFLEN 256
- char buf[3][BUFLEN];
char *tofree = NULL;
const char *errstr = NULL;
DB_ATTR db_attr;
if (sk_X509_num(cert_sk) > 0) {
if (!batch) {
+ char answer[10];
+
BIO_printf(bio_err, "\n%d out of %d certificate requests certified, commit? [y/n]", total_done, total);
(void) BIO_flush(bio_err);
- buf[0][0] = '\0';
- if (!fgets(buf[0], 10, stdin)) {
+ if (!fgets(answer, sizeof answer - 1, stdin)) {
BIO_printf(bio_err, "CERTIFICATION CANCELED: I/O error\n");
ret = 0;
goto err;
}
- if ((buf[0][0] != 'y') && (buf[0][0] != 'Y')) {
+ if ((answer[0] != 'y') && (answer[0] != 'Y')) {
BIO_printf(bio_err, "CERTIFICATION CANCELED\n");
ret = 0;
goto err;
int k;
char *serialstr;
unsigned char *data;
+ char pempath[PATH_MAX];
x = sk_X509_value(cert_sk, i);
else
serialstr = strdup("00");
if (serialstr) {
- k = snprintf(buf[2], sizeof(buf[2]),
+ k = snprintf(pempath, sizeof(pempath),
"%s/%s.pem", outdir, serialstr);
free(serialstr);
- if (k == -1 || k >= sizeof(buf[2])) {
+ if (k == -1 || k >= sizeof(pempath)) {
BIO_printf(bio_err,
"certificate file name too long\n");
goto err;
goto err;
}
if (verbose)
- BIO_printf(bio_err, "writing %s\n", buf[2]);
+ BIO_printf(bio_err, "writing %s\n", pempath);
- if (BIO_write_filename(Cout, buf[2]) <= 0) {
- perror(buf[2]);
+ if (BIO_write_filename(Cout, pempath) <= 0) {
+ perror(pempath);
goto err;
}
write_new_certificate(Cout, x, 0, notext);
OPENSSL_STRING row[DB_NUMBER];
OPENSSL_STRING *irow = NULL;
OPENSSL_STRING *rrow = NULL;
- char buf[25];
tmptm = ASN1_UTCTIME_new();
if (tmptm == NULL) {
BIO_printf(bio_err, "\n");
if (!batch) {
+ char answer[25];
BIO_printf(bio_err, "Sign the certificate? [y/n]:");
(void) BIO_flush(bio_err);
- buf[0] = '\0';
- if (!fgets(buf, sizeof(buf) - 1, stdin)) {
+ if (!fgets(answer, sizeof(answer) - 1, stdin)) {
BIO_printf(bio_err,
"CERTIFICATE WILL NOT BE CERTIFIED: I/O error\n");
ok = 0;
goto err;
}
- if (!((buf[0] == 'y') || (buf[0] == 'Y'))) {
+ if (!((answer[0] == 'y') || (answer[0] == 'Y'))) {
BIO_printf(bio_err,
"CERTIFICATE WILL NOT BE CERTIFIED\n");
ok = 0;