summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2002-12-26 15:50:45 +0000
committernyan <nyan@FreeBSD.org>2002-12-26 15:50:45 +0000
commit63904a7353092f3584797723f05e330d2ce5783b (patch)
treec1317afdfb33b7c0e33a58240a0377cc998dff0c
parent2b2581b1ef8adf71666fd19d9634f51f62dad22d (diff)
downloadFreeBSD-src-63904a7353092f3584797723f05e330d2ce5783b.zip
FreeBSD-src-63904a7353092f3584797723f05e330d2ce5783b.tar.gz
Return an error if the size of the sector is zero. This is for removable
devices that is not inserted any media. This is MFC candidate. Submitted by: ISAKA Yoji <isaka@cory.jp>
-rw-r--r--lib/libdisk/disk.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libdisk/disk.c b/lib/libdisk/disk.c
index c0c5c51..2341459 100644
--- a/lib/libdisk/disk.c
+++ b/lib/libdisk/disk.c
@@ -166,6 +166,8 @@ Int_Open_Disk(const char *name)
exit (0);
}
+ if (s == 0)
+ return (NULL);
d->sector_size = s;
len /= s; /* media size in number of sectors. */
@@ -481,6 +483,8 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
{
#if !defined(__ia64__)
#ifdef PC98
+ if (d->sector_size == 0)
+ return;
if (bootipl_size % d->sector_size != 0)
return;
if (d->bootipl)
@@ -509,6 +513,8 @@ Set_Boot_Mgr(struct disk *d, const u_char *b, const size_t s)
memcpy(d->bootmenu, bootmenu, bootmenu_size);
}
#else
+ if (d->sector_size == 0)
+ return;
if (s % d->sector_size != 0)
return;
if (d->bootmgr)
OpenPOWER on IntegriCloud