From 993e4236e02253e42e6aae5205c48133d5b5fa6d Mon Sep 17 00:00:00 2001 From: krw Date: Sun, 6 Nov 2022 12:33:41 +0000 Subject: [PATCH] Don't leak args.fspec in create_filesystem(). ok kn@ --- usr.sbin/installboot/efi_installboot.c | 5 ++++- usr.sbin/installboot/i386_installboot.c | 5 ++++- usr.sbin/installboot/macppc_installboot.c | 5 ++++- usr.sbin/installboot/octeon_installboot.c | 5 ++++- usr.sbin/installboot/powerpc64_installboot.c | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/usr.sbin/installboot/efi_installboot.c b/usr.sbin/installboot/efi_installboot.c index b0b26b8a4e5..77e7130e441 100644 --- a/usr.sbin/installboot/efi_installboot.c +++ b/usr.sbin/installboot/efi_installboot.c @@ -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; } diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index b637c08e607..8ecb5ba151f 100644 --- a/usr.sbin/installboot/i386_installboot.c +++ b/usr.sbin/installboot/i386_installboot.c @@ -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; } diff --git a/usr.sbin/installboot/macppc_installboot.c b/usr.sbin/installboot/macppc_installboot.c index a8144bcbbde..877ae125882 100644 --- a/usr.sbin/installboot/macppc_installboot.c +++ b/usr.sbin/installboot/macppc_installboot.c @@ -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 @@ -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; } diff --git a/usr.sbin/installboot/octeon_installboot.c b/usr.sbin/installboot/octeon_installboot.c index 75d8bf969b6..2b1fa4ea843 100644 --- a/usr.sbin/installboot/octeon_installboot.c +++ b/usr.sbin/installboot/octeon_installboot.c @@ -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 @@ -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; } diff --git a/usr.sbin/installboot/powerpc64_installboot.c b/usr.sbin/installboot/powerpc64_installboot.c index a8d07f0fd40..c4765ab0c0d 100644 --- a/usr.sbin/installboot/powerpc64_installboot.c +++ b/usr.sbin/installboot/powerpc64_installboot.c @@ -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 @@ -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; } -- 2.20.1