diff options
author | jkh <jkh@FreeBSD.org> | 1999-05-12 23:08:02 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1999-05-12 23:08:02 +0000 |
commit | 20b81702c7b5e256780ed9a42fbe5916a42db42c (patch) | |
tree | e66ea74854422ba6a0839519a27bb7ca67a8de30 /release | |
parent | dcfeb7e2deea3ce4e0d4196ab6cd66e4a0f21b4b (diff) | |
download | FreeBSD-src-20b81702c7b5e256780ed9a42fbe5916a42db42c.zip FreeBSD-src-20b81702c7b5e256780ed9a42fbe5916a42db42c.tar.gz |
Correct a bug which could cause a segfault if there is no uc_devlist
data.
Noticed by: Bill Swingle <bill@cdrom.com>
Diffstat (limited to 'release')
-rw-r--r-- | release/sysinstall/kget.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/release/sysinstall/kget.c b/release/sysinstall/kget.c index 325cdaa..4b7ee84 100644 --- a/release/sysinstall/kget.c +++ b/release/sysinstall/kget.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kget.c,v 1.7 1999/05/06 11:03:17 jkh Exp $ + * $Id: kget.c,v 1.8 1999/05/07 04:36:20 jkh Exp $ */ #include "sysinstall.h" @@ -44,12 +44,20 @@ kget(char *out) struct pnp_cinfo *c; char *p; + /* create the output file; if we end up not writing to it, we'll + unlink() it later. */ + fout = fopen(out, "w"); + if (fout == NULL) { + msgDebug("kget: Unable to open %s for writing.\n", out); + return -1; + } + /* We use sysctlbyname, because the oid is unknown (OID_AUTO) */ /* get the buffer size */ i = sysctlbyname(mib1, NULL, &len, NULL, NULL); if (i) { msgDebug("kget: error buffer sizing\n"); - return -1; + goto pnp; } if (len <= 0) { msgDebug("kget: mib1 has length of %d\n", len); @@ -59,16 +67,9 @@ kget(char *out) i = sysctlbyname(mib1, buf, &len, NULL, NULL); if (i) { msgDebug("kget: error retrieving data\n"); - return -1; + goto pnp; } - /* now it's time to create the output file; if we end up not writing to - it, we'll unlink() it later. */ - fout = fopen(out, "w"); - if (fout == NULL) { - msgDebug("kget: Unable to open %s for writing.\n", out); - return -1; - } i = 0; while (i < len) { |