diff options
author | Dima Dorfman <dd@FreeBSD.org> | 2001-07-02 00:18:04 +0000 |
---|---|---|
committer | Dima Dorfman <dd@FreeBSD.org> | 2001-07-02 00:18:04 +0000 |
commit | 13704ca508967d083346df8d9ed32bdfa51bf38c (patch) | |
tree | eb3e6d3ae80fce772bbe283df44e815263d1b83f /usr.sbin/sysinstall/dist.c | |
parent | 0c2e00bb8f535911955ff05eba0d1aba3e0cd72c (diff) | |
download | src-13704ca508967d083346df8d9ed32bdfa51bf38c.tar.gz src-13704ca508967d083346df8d9ed32bdfa51bf38c.zip |
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)
Notes
Notes:
svn path=/head/; revision=79065
Diffstat (limited to 'usr.sbin/sysinstall/dist.c')
-rw-r--r-- | usr.sbin/sysinstall/dist.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index 488dd5a089ed..1f8f5fc107ec 100644 --- a/usr.sbin/sysinstall/dist.c +++ b/usr.sbin/sysinstall/dist.c @@ -605,14 +605,14 @@ distExtract(char *parent, Distribution *me) snprintf(buf, sizeof buf, "%s/%s.inf", path, dist); getinfo: - fp = mediaDevice->get(mediaDevice, buf, TRUE); + fp = DEVICE_GET(mediaDevice, buf, TRUE); intr = check_for_interrupt(); if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) { /* Hard error, can't continue */ if (!msgYesNo("Unable to open %s: %s.\nReinitialize media?", buf, !intr ? "I/O error." : "User interrupt.")) { - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) { + DEVICE_SHUTDOWN(mediaDevice); + if (!DEVICE_INIT(mediaDevice)) { status = FALSE; goto done; } @@ -652,7 +652,7 @@ distExtract(char *parent, Distribution *me) * are not considered too significant. */ getsingle: - fp = mediaDevice->get(mediaDevice, buf, TRUE); + fp = DEVICE_GET(mediaDevice, buf, TRUE); intr = check_for_interrupt(); if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) { /* Hard error, can't continue */ @@ -660,8 +660,8 @@ distExtract(char *parent, Distribution *me) msgConfirm("Unable to open %s: User interrupt", buf); else msgConfirm("Unable to open %s: I/O error", buf); - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) { + DEVICE_SHUTDOWN(mediaDevice); + if (!DEVICE_INIT(mediaDevice)) { status = FALSE; goto done; } @@ -715,7 +715,7 @@ distExtract(char *parent, Distribution *me) snprintf(buf, sizeof buf, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); if (isDebug()) msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks, buf); - fp = mediaDevice->get(mediaDevice, buf, FALSE); + fp = DEVICE_GET(mediaDevice, buf, FALSE); intr = check_for_interrupt(); if (fp <= (FILE *)0 || intr) { if (fp == (FILE *)0) @@ -723,8 +723,8 @@ distExtract(char *parent, Distribution *me) else msgConfirm("failed to retreive piece file %s.\n" "%s: Reinitializing media.", buf, !intr ? "I/O error" : "User interrupt"); - mediaDevice->shutdown(mediaDevice); - if (!mediaDevice->init(mediaDevice)) + DEVICE_SHUTDOWN(mediaDevice); + if (!DEVICE_INIT(mediaDevice)) goto punt; else goto getchunk; @@ -867,7 +867,7 @@ distExtractAll(dialogMenuItem *self) return DITEM_FAILURE; } - if (!mediaVerify() || !mediaDevice->init(mediaDevice)) + if (!mediaVerify() || !DEVICE_INIT(mediaDevice)) return DITEM_FAILURE; old_dists = Dists; |