diff options
author | dd <dd@FreeBSD.org> | 2001-07-02 00:18:04 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-07-02 00:18:04 +0000 |
commit | 4a798fb83a60241d607536db8b69d9709995a803 (patch) | |
tree | eb3e6d3ae80fce772bbe283df44e815263d1b83f /usr.sbin/sysinstall/install.c | |
parent | b1763d41ddf8b57a46b69e3e8423b9d57392bd6a (diff) | |
download | FreeBSD-src-4a798fb83a60241d607536db8b69d9709995a803.zip FreeBSD-src-4a798fb83a60241d607536db8b69d9709995a803.tar.gz |
Introduce DEVICE_INIT, DEVICE_GET, and DEVICE_SHUTDOWN macros. As the
names suggest, they perform methods on Device's. In addition, they
check that the pointer passed to them is valid; if it isn't, they
pretend that the action failed. This fixes some crashes due to NULL
dereferences (e.g., PR 26509).
Approved by: jkh (some time ago)
Diffstat (limited to 'usr.sbin/sysinstall/install.c')
-rw-r--r-- | usr.sbin/sysinstall/install.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index d5820a6..3d8539f 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -269,8 +269,9 @@ installFixitCDROM(dialogMenuItem *self) (void)rmdir("/mnt2"); while (1) { - msgConfirm("Please insert a FreeBSD live filesystem CD/DVD and press return"); - if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) { + msgConfirm("Please insert a FreeBSD live filesystem CDROM and press return"); + if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS + || !DEVICE_INIT(mediaDevice)) { /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */ mediaClose(); if (msgYesNo("Unable to mount the disc - do you want to try again?") != 0) @@ -357,7 +358,7 @@ installFixitFloppy(dialogMenuItem *self) variable_set2(SYSTEM_STATE, "fixit", 0); while (1) { - if (!mediaDevice->init(mediaDevice)) { + if (!DEVICE_INIT(mediaDevice)) { if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n" "or unclean filesystem. Do you want to try again?")) return DITEM_FAILURE; @@ -562,7 +563,7 @@ nodisks: Device *tmp = tcpDeviceSelect(); if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name)) - if (!tmp->init(tmp)) + if (!DEVICE_INIT(tmp)) msgConfirm("Initialization of %s device failed.", tmp->name); } dialog_clear_norefresh(); @@ -702,7 +703,7 @@ installCommit(dialogMenuItem *self) return i; try_media: - if (!mediaDevice->init(mediaDevice)) { + if (!DEVICE_INIT(mediaDevice)) { if (!msgYesNo("Unable to initialize selected media. Would you like to\n" "adjust your media configuration and try again?")) { mediaDevice = NULL; |