From: claudio Date: Tue, 26 Oct 2021 16:59:54 +0000 (+0000) Subject: Adjust regress to the new BIO-free world order. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=db11ffcf7e4778be999f239aeea7b6cca0eab358;p=openbsd Adjust regress to the new BIO-free world order. --- diff --git a/regress/usr.sbin/rpki-client/test-cert.c b/regress/usr.sbin/rpki-client/test-cert.c index 1a56eedd4e3..50cba22e53b 100644 --- a/regress/usr.sbin/rpki-client/test-cert.c +++ b/regress/usr.sbin/rpki-client/test-cert.c @@ -1,4 +1,4 @@ -/* $Id: test-cert.c,v 1.14 2021/10/24 17:54:28 claudio Exp $ */ +/* $Id: test-cert.c,v 1.15 2021/10/26 16:59:54 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -71,15 +71,19 @@ main(int argc, char *argv[]) const char *cert_path = argv[i]; const char *tal_path = argv[i + 1]; char *buf; + size_t len; struct tal *tal; - buf = tal_read_file(tal_path); - tal = tal_parse(tal_path, buf); + buf = load_file(tal_path, &len); + tal = tal_parse(tal_path, buf, len); free(buf); if (tal == NULL) break; - p = ta_parse(&xp, cert_path, tal->pkey, tal->pkeysz); + buf = load_file(cert_path, &len); + p = ta_parse(&xp, cert_path, buf, len, + tal->pkey, tal->pkeysz); + free(buf); tal_free(tal); if (p == NULL) break; @@ -91,11 +95,16 @@ main(int argc, char *argv[]) } } else { for (i = 0; i < argc; i++) { - p = cert_parse(&xp, argv[i]); + char *buf; + size_t len; + + buf = load_file(argv[i], &len); + p = cert_parse(&xp, argv[i], buf, len); if (p == NULL) break; if (verb) cert_print(p); + free(buf); cert_free(p); X509_free(xp); } diff --git a/regress/usr.sbin/rpki-client/test-gbr.c b/regress/usr.sbin/rpki-client/test-gbr.c index cca4977384b..b7310516d56 100644 --- a/regress/usr.sbin/rpki-client/test-gbr.c +++ b/regress/usr.sbin/rpki-client/test-gbr.c @@ -1,4 +1,4 @@ -/* $Id: test-gbr.c,v 1.4 2021/10/24 17:54:28 claudio Exp $ */ +/* $Id: test-gbr.c,v 1.5 2021/10/26 16:59:54 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -39,6 +39,8 @@ main(int argc, char *argv[]) BIO *bio_out = NULL; X509 *xp = NULL; struct gbr *p; + unsigned char *buf; + size_t len; ERR_load_crypto_strings(); @@ -68,8 +70,11 @@ main(int argc, char *argv[]) errx(1, "argument missing"); for (i = 0; i < argc; i++) { - if ((p = gbr_parse(&xp, argv[i])) == NULL) - break; + buf = load_file(argv[1], &len); + if ((p = gbr_parse(&xp, argv[i], buf, len)) == NULL) { + free(buf); + continue; + } if (verb) gbr_print(p); if (ppem) { @@ -77,6 +82,7 @@ main(int argc, char *argv[]) errx(1, "PEM_write_bio_X509: unable to write cert"); } + free(buf); gbr_free(p); X509_free(xp); } diff --git a/regress/usr.sbin/rpki-client/test-mft.c b/regress/usr.sbin/rpki-client/test-mft.c index 7d0343907f8..fe7a08b0e09 100644 --- a/regress/usr.sbin/rpki-client/test-mft.c +++ b/regress/usr.sbin/rpki-client/test-mft.c @@ -1,4 +1,4 @@ -/* $Id: test-mft.c,v 1.16 2021/10/24 17:54:28 claudio Exp $ */ +/* $Id: test-mft.c,v 1.17 2021/10/26 16:59:54 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -42,6 +42,8 @@ main(int argc, char *argv[]) struct mft *p; BIO *bio_out = NULL; X509 *xp = NULL; + unsigned char *buf; + size_t len; ERR_load_crypto_strings(); OpenSSL_add_all_ciphers(); @@ -70,8 +72,11 @@ main(int argc, char *argv[]) errx(1, "argument missing"); for (i = 0; i < argc; i++) { - if ((p = mft_parse(&xp, argv[i])) == NULL) - break; + buf = load_file(argv[i], &len); + if ((p = mft_parse(&xp, argv[i], buf, len)) == NULL) { + free(buf); + continue; + } if (verb) mft_print(p); if (ppem) { @@ -79,6 +84,7 @@ main(int argc, char *argv[]) errx(1, "PEM_write_bio_X509: unable to write cert"); } + free(buf); mft_free(p); X509_free(xp); } diff --git a/regress/usr.sbin/rpki-client/test-roa.c b/regress/usr.sbin/rpki-client/test-roa.c index 4824e028d80..ff71bcf1a9e 100644 --- a/regress/usr.sbin/rpki-client/test-roa.c +++ b/regress/usr.sbin/rpki-client/test-roa.c @@ -1,4 +1,4 @@ -/* $Id: test-roa.c,v 1.13 2021/10/24 17:54:28 claudio Exp $ */ +/* $Id: test-roa.c,v 1.14 2021/10/26 16:59:54 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -39,7 +39,8 @@ main(int argc, char *argv[]) BIO *bio_out = NULL; X509 *xp = NULL; struct roa *p; - + unsigned char *buf; + size_t len; ERR_load_crypto_strings(); OpenSSL_add_all_ciphers(); @@ -68,8 +69,11 @@ main(int argc, char *argv[]) errx(1, "argument missing"); for (i = 0; i < argc; i++) { - if ((p = roa_parse(&xp, argv[i])) == NULL) - break; + buf = load_file(argv[i], &len); + if ((p = roa_parse(&xp, argv[i], buf, len)) == NULL) { + free(buf); + continue; + } if (verb) roa_print(p); if (ppem) { @@ -77,6 +81,7 @@ main(int argc, char *argv[]) errx(1, "PEM_write_bio_X509: unable to write cert"); } + free(buf); roa_free(p); X509_free(xp); } diff --git a/regress/usr.sbin/rpki-client/test-tal.c b/regress/usr.sbin/rpki-client/test-tal.c index dedd329f08a..965813ba5b4 100644 --- a/regress/usr.sbin/rpki-client/test-tal.c +++ b/regress/usr.sbin/rpki-client/test-tal.c @@ -1,4 +1,4 @@ -/* $Id: test-tal.c,v 1.7 2021/10/24 17:54:28 claudio Exp $ */ +/* $Id: test-tal.c,v 1.8 2021/10/26 16:59:54 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -36,6 +36,7 @@ main(int argc, char *argv[]) { int c, i, verb = 0; char *buf; + size_t len; struct tal *tal; ERR_load_crypto_strings(); @@ -58,8 +59,8 @@ main(int argc, char *argv[]) errx(1, "argument missing"); for (i = 0; i < argc; i++) { - buf = tal_read_file(argv[i]); - tal = tal_parse(argv[i], buf); + buf = load_file(argv[i], &len); + tal = tal_parse(argv[i], buf, len); free(buf); if (tal == NULL) break;