Article View: comp.bugs.4bsd
Article #137Minor disk label bug
From: ed Ed Gould
Date: Wed, 15 Nov 1989 00:55
Date: Wed, 15 Nov 1989 00:55
55 lines
1909 bytes
1909 bytes
Description:
If a disk label has correct magic numbers but a badly
corrupted number of partitions, then the checksum routine
may run wild.
Repeat-By:
Corrupt a label suitably,
Fix:
Make the code that looks for the label more defensive.
This has the effect of not accepting a label that would
otherwise be correct except for a too-large number of
partitions.
*** /usr/tahoesrc/sys/sys/ufs_disksubr.c Sat Jun 11 18:54:43 1988
--- sys/ufs_disksubr.c Tue Nov 14 16:14:56 1989
***************
*** 157,165 ****
dlp <= (struct disklabel *)(bp->b_un.b_addr+DEV_BSIZE-sizeof(*dlp));
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
if (msg == NULL)
msg = "no disk label";
! } else if (dkcksum(dlp) != 0)
msg = "disk label corrupted";
else {
*lp = *dlp;
--- 157,166 ----
dlp <= (struct disklabel *)(bp->b_un.b_addr+DEV_BSIZE-sizeof(*dlp));
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
if (msg == NULL)
msg = "no disk label";
! } else if (dlp->d_npartitions > MAXPARTITIONS ||
! dkcksum(dlp) != 0)
msg = "disk label corrupted";
else {
*lp = *dlp;
***************
*** 166,180 ****
msg = NULL;
break;
}
}
- if (lp->d_npartitions > MAXPARTITIONS)
- lp->d_npartitions = MAXPARTITIONS;
bp->b_flags = B_INVAL | B_AGE;
brelse(bp);
return (msg);
}
/*
* Check new disk label for sensibility
* before setting it.
*/
Technical Details
Message-ID:
<1052@mtxinu.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mtxinu!edShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mtxinu!ed From: ed (Ed Gould) Newsgroups: comp.bugs.4bsd Subject: Minor disk label bug Message-ID: <1052@mtxinu.UUCP> Date: 15 Nov 89 00:55:47 GMT Sender: ed@mtxinu.COM Lines: 55