summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/openssl/apps.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index b6ceaeabb8..46197dfd49 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.71 2025/03/17 15:55:09 tb Exp $ */ 1/* $OpenBSD: apps.c,v 1.72 2025/03/18 13:03:08 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -1377,10 +1377,10 @@ int
1377save_index(const char *file, const char *suffix, CA_DB *db) 1377save_index(const char *file, const char *suffix, CA_DB *db)
1378{ 1378{
1379 char attrpath[PATH_MAX], dbfile[PATH_MAX]; 1379 char attrpath[PATH_MAX], dbfile[PATH_MAX];
1380 BIO *out = BIO_new(BIO_s_file()); 1380 BIO *out;
1381 int j; 1381 int ret = 0;
1382 1382
1383 if (out == NULL) { 1383 if ((out = BIO_new(BIO_s_file())) == NULL) {
1384 ERR_print_errors(bio_err); 1384 ERR_print_errors(bio_err);
1385 goto err; 1385 goto err;
1386 } 1386 }
@@ -1400,28 +1400,31 @@ save_index(const char *file, const char *suffix, CA_DB *db)
1400 BIO_printf(bio_err, "unable to open '%s'\n", dbfile); 1400 BIO_printf(bio_err, "unable to open '%s'\n", dbfile);
1401 goto err; 1401 goto err;
1402 } 1402 }
1403 j = TXT_DB_write(out, db->db); 1403
1404 if (j <= 0) 1404 if (TXT_DB_write(out, db->db) <= 0)
1405 goto err; 1405 goto err;
1406 1406
1407 BIO_free(out); 1407 BIO_free(out);
1408 1408 if ((out = BIO_new(BIO_s_file())) == NULL) {
1409 out = BIO_new(BIO_s_file()); 1409 ERR_print_errors(bio_err);
1410 goto err;
1411 }
1410 1412
1411 if (BIO_write_filename(out, attrpath) <= 0) { 1413 if (BIO_write_filename(out, attrpath) <= 0) {
1412 perror(attrpath); 1414 perror(attrpath);
1413 BIO_printf(bio_err, "unable to open '%s'\n", attrpath); 1415 BIO_printf(bio_err, "unable to open '%s'\n", attrpath);
1414 goto err; 1416 goto err;
1415 } 1417 }
1416 BIO_printf(out, "unique_subject = %s\n", 1418 if (BIO_printf(out, "unique_subject = %s\n",
1417 db->attributes.unique_subject ? "yes" : "no"); 1419 db->attributes.unique_subject ? "yes" : "no") <= 0)
1418 BIO_free(out); 1420 goto err;
1419 1421
1420 return 1; 1422 ret = 1;
1421 1423
1422 err: 1424 err:
1423 BIO_free(out); 1425 BIO_free(out);
1424 return 0; 1426
1427 return ret;
1425} 1428}
1426 1429
1427int 1430int