Adjust regress to the new BIO-free world order.
authorclaudio <claudio@openbsd.org>
Tue, 26 Oct 2021 16:59:54 +0000 (16:59 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 26 Oct 2021 16:59:54 +0000 (16:59 +0000)
regress/usr.sbin/rpki-client/test-cert.c
regress/usr.sbin/rpki-client/test-gbr.c
regress/usr.sbin/rpki-client/test-mft.c
regress/usr.sbin/rpki-client/test-roa.c
regress/usr.sbin/rpki-client/test-tal.c

index 1a56eed..50cba22 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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);
                }
index cca4977..b731051 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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);
        }
index 7d03439..fe7a08b 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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);
        }
index 4824e02..ff71bcf 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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);
        }
index dedd329..965813b 100644 (file)
@@ -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 <kristaps@bsd.lv>
  *
@@ -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;