Don't leak args.fspec in create_filesystem().
authorkrw <krw@openbsd.org>
Sun, 6 Nov 2022 12:33:41 +0000 (12:33 +0000)
committerkrw <krw@openbsd.org>
Sun, 6 Nov 2022 12:33:41 +0000 (12:33 +0000)
ok kn@

usr.sbin/installboot/efi_installboot.c
usr.sbin/installboot/i386_installboot.c
usr.sbin/installboot/macppc_installboot.c
usr.sbin/installboot/octeon_installboot.c
usr.sbin/installboot/powerpc64_installboot.c

index b0b26b8..77e7130 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: efi_installboot.c,v 1.6 2022/09/14 16:43:00 kn Exp $  */
+/*     $OpenBSD: efi_installboot.c,v 1.7 2022/11/06 12:33:41 krw Exp $ */
 /*     $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
 
 /*
@@ -166,6 +166,7 @@ create_filesystem(struct disklabel *dl, char part)
        rslt = snprintf(cmd, sizeof(cmd), newfsfmt, args.fspec);
        if (rslt >= sizeof(cmd)) {
                warnx("can't build newfs command");
+               free(args.fspec);
                rslt = -1;
                return rslt;
        }
@@ -177,10 +178,12 @@ create_filesystem(struct disklabel *dl, char part)
                rslt = system(cmd);
                if (rslt == -1) {
                        warn("system('%s') failed", cmd);
+                       free(args.fspec);
                        return rslt;
                }
        }
 
+       free(args.fspec);
        return 0;
 }
 
index b637c08..8ecb5ba 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: i386_installboot.c,v 1.43 2022/09/14 16:43:00 kn Exp $        */
+/*     $OpenBSD: i386_installboot.c,v 1.44 2022/11/06 12:33:41 krw Exp $       */
 /*     $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
 
 /*
@@ -267,6 +267,7 @@ create_filesystem(struct disklabel *dl, char part)
        rslt = snprintf(cmd, sizeof(cmd), newfsfmt, args.fspec);
        if (rslt >= sizeof(cmd)) {
                warnx("can't build newfs command");
+               free(args.fspec);
                rslt = -1;
                return rslt;
        }
@@ -278,10 +279,12 @@ create_filesystem(struct disklabel *dl, char part)
                rslt = system(cmd);
                if (rslt == -1) {
                        warn("system('%s') failed", cmd);
+                       free(args.fspec);
                        return rslt;
                }
        }
 
+       free(args.fspec);
        return 0;
 }
 
index a8144bc..877ae12 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: macppc_installboot.c,v 1.8 2022/09/14 16:43:00 kn Exp $       */
+/*     $OpenBSD: macppc_installboot.c,v 1.9 2022/11/06 12:33:41 krw Exp $      */
 
 /*
  * Copyright (c) 2011 Joel Sing <jsing@openbsd.org>
@@ -138,6 +138,7 @@ create_filesystem(struct disklabel *dl, char part)
        rslt = snprintf(cmd, sizeof(cmd), newfsfmt, args.fspec);
        if (rslt >= sizeof(cmd)) {
                warnx("can't build newfs command");
+               free(args.fspec);
                rslt = -1;
                return rslt;
        }
@@ -149,10 +150,12 @@ create_filesystem(struct disklabel *dl, char part)
                rslt = system(cmd);
                if (rslt == -1) {
                        warn("system('%s') failed", cmd);
+                       free(args.fspec);
                        return rslt;
                }
        }
 
+       free(args.fspec);
        return 0;
 }
 
index 75d8bf9..2b1fa4e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: octeon_installboot.c,v 1.8 2022/09/27 11:42:16 kn Exp $       */
+/*     $OpenBSD: octeon_installboot.c,v 1.9 2022/11/06 12:33:41 krw Exp $      */
 
 /*
  * Copyright (c) 2011 Joel Sing <jsing@openbsd.org>
@@ -138,6 +138,7 @@ create_filesystem(struct disklabel *dl, char part)
        rslt = snprintf(cmd, sizeof(cmd), newfsfmt, args.fspec);
        if (rslt >= sizeof(cmd)) {
                warnx("can't build newfs command");
+               free(args.fspec);
                rslt = -1;
                return rslt;
        }
@@ -149,10 +150,12 @@ create_filesystem(struct disklabel *dl, char part)
                rslt = system(cmd);
                if (rslt == -1) {
                        warn("system('%s') failed", cmd);
+                       free(args.fspec);
                        return rslt;
                }
        }
 
+       free(args.fspec);
        return 0;
 }
 
index a8d07f0..c4765ab 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: powerpc64_installboot.c,v 1.7 2022/09/27 11:31:46 kn Exp $    */
+/*     $OpenBSD: powerpc64_installboot.c,v 1.8 2022/11/06 12:33:41 krw Exp $   */
 
 /*
  * Copyright (c) 2011 Joel Sing <jsing@openbsd.org>
@@ -145,6 +145,7 @@ create_filesystem(struct disklabel *dl, char part)
        rslt = snprintf(cmd, sizeof(cmd), newfsfmt, args.fspec);
        if (rslt >= sizeof(cmd)) {
                warnx("can't build newfs command");
+               free(args.fspec);
                rslt = -1;
                return rslt;
        }
@@ -156,10 +157,12 @@ create_filesystem(struct disklabel *dl, char part)
                rslt = system(cmd);
                if (rslt == -1) {
                        warn("system('%s') failed", cmd);
+                       free(args.fspec);
                        return rslt;
                }
        }
 
+       free(args.fspec);
        return 0;
 }