Subject: bin/2683: disklabel can try to divide by zero
To: None <gnats-bugs@NetBSD.ORG>
From: Nathan J Williams <nathanw@MIT.EDU>
List: netbsd-bugs
Date: 08/10/1996 01:18:31
>Number: 2683
>Category: bin
>Synopsis: disklabel can try to divide by zero
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 10 01:35:01 1996
>Last-Modified:
>Originator: Nathan J Williams
>Organization:
>Release: 1.2_BETA, roughly
>Environment:
NetBSD disc-gun 1.1 NetBSD 1.1 (GENERIC) #7: Tue Nov 21 20:16:32 MET 1995 pk@neon:/usr/src1/sys/arch/sparc/compile/GENERIC sparc
>Description:
>How-To-Repeat:
Run disklabel on a SMD (7053 only?) disk that doesn't have a label.
It coredumps with an FP exception, after trying to come up with a comment
field for the returned partition when lp->d_secpercyl is 0.
>Fix:
Avoid the "# (Cyl. xxx - yyyy )" comment when lp->d_secpercyl is 0.
Arguably, the xd driver should return 0 partitions instead of 1 empty
partition, but I don't consider this a problem.
*** disklabel.c.orig Sat Aug 10 00:54:06 1996
--- disklabel.c Sat Aug 10 00:57:59 1996
***************
*** 826,831 ****
--- 826,832 ----
fprintf(f, "%20.20s", "");
break;
}
+ if(lp->d_secpercyl!=0) {
fprintf(f, "\t# (Cyl. %4d",
pp->p_offset / lp->d_secpercyl);
if (pp->p_offset % lp->d_secpercyl)
***************
*** 839,844 ****
--- 840,848 ----
if (pp->p_size % lp->d_secpercyl)
putc('*', f);
fprintf(f, ")\n");
+ }
+ else
+ fprintf(f,"\n");
}
}
fflush(f);
>Audit-Trail:
>Unformatted: