diff options
-rw-r--r-- | sys/arch/pmax/pmax/disksubr.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/arch/pmax/pmax/disksubr.c b/sys/arch/pmax/pmax/disksubr.c index 76ccc58fae0..d0e43b779aa 100644 --- a/sys/arch/pmax/pmax/disksubr.c +++ b/sys/arch/pmax/pmax/disksubr.c @@ -202,9 +202,21 @@ setdisklabel(olp, nlp, openmask, osdep) register i; register struct partition *opp, *npp; + /* sanity clause */ + if (nlp->d_secpercyl == 0 || nlp->d_secsize == 0 || + (nlp->d_secsize % DEV_BSIZE) != 0) + return(EINVAL); + + /* special case to allow disklabel to be invalidated */ + if (nlp->d_magic == 0xffffffff) { + *olp = *nlp; + return (0); + } + if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC || dkcksum(nlp) != 0) return (EINVAL); + while ((i = ffs((long)openmask)) != 0) { i--; openmask &= ~(1 << i); |