diff options
author | Toomas Soome <tsoome@me.com> | 2018-06-16 15:17:37 +0300 |
---|---|---|
committer | Hans Rosenfeld <hans.rosenfeld@joyent.com> | 2018-07-09 18:33:58 +0200 |
commit | bc85f3b0d8cbf8037263b0d2ae7587f25ab35394 (patch) | |
tree | e0ef78402b4b188c43db44c2eaf24fb366fa3afe | |
parent | 00f1a4f432b3d8aad1aa270e91c44c57f03ef407 (diff) | |
download | illumos-joyent-bc85f3b0d8cbf8037263b0d2ae7587f25ab35394.tar.gz |
9613 loader: Fix some resource leaks in common/boot.c
Reviewed by: Yuri Pankov <yuripv@yuripv.net>
Approved by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
-rw-r--r-- | usr/src/boot/sys/boot/common/boot.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/usr/src/boot/sys/boot/common/boot.c b/usr/src/boot/sys/boot/common/boot.c index 2f6b7f1f78..349fa5f9e8 100644 --- a/usr/src/boot/sys/boot/common/boot.c +++ b/usr/src/boot/sys/boot/common/boot.c @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> * All rights reserved. * @@ -25,7 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); /* * Loading modules, booting the system @@ -307,6 +306,8 @@ getrootmount(char *rootdev) goto notfound; /* loop reading lines from /etc/fstab What was that about sscanf again? */ + fstyp = NULL; + dev = NULL; while (fgetstr(lbuf, sizeof(lbuf), fd) >= 0) { if ((lbuf[0] == 0) || (lbuf[0] == '#')) continue; @@ -318,6 +319,7 @@ getrootmount(char *rootdev) continue; /* delimit and save */ *cp++ = 0; + free(dev); dev = strdup(lbuf); /* skip whitespace up to mountpoint */ @@ -337,6 +339,7 @@ getrootmount(char *rootdev) while ((*cp != 0) && !isspace(*cp)) cp++; *cp = 0; + free(fstyp); fstyp = strdup(ep); /* skip whitespace up to mount options */ @@ -353,8 +356,6 @@ getrootmount(char *rootdev) options = strdup(ep); /* Build the <fstype>:<device> and save it in vfs.root.mountfrom */ sprintf(lbuf, "%s:%s", fstyp, dev); - free(dev); - free(fstyp); setenv("vfs.root.mountfrom", lbuf, 0); /* Don't override vfs.root.mountfrom.options if it is already set */ @@ -367,6 +368,8 @@ getrootmount(char *rootdev) break; } close(fd); + free(dev); + free(fstyp); notfound: if (error) { @@ -378,6 +381,7 @@ notfound: cp[strlen(cp) - 1] = '\0'; setenv("vfs.root.mountfrom", cp, 0); error = 0; + free(cp); } } |