Subject: misc/490: disklabel dumps core instead of warning on bad format
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: John Kohl <jtk@kolvir.blrc.ma.us>
List: netbsd-bugs
Date: 09/19/1994 19:05:08
>Number: 490
>Category: misc
>Synopsis: disklabel dumps core instead of warning on bad format
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: gnats-admin (Misc Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 19 19:05:05 1994
>Originator: John Kohl
>Organization:
>Release: NetBSD-1.0_BETA
>Environment:
NetBSD-1.0_BETA, i486/33, 16MB memory
System: NetBSD kolvir 1.0_BETA NetBSD 1.0_BETA (KOLVIR) #17: Sun Sep 18 22:09:55 EDT 1994 jtk@kolvir:/u1/NetBSD-1.0/src/sys/arch/i386/compile/KOLVIR i386
>Description:
disklabel will dump core if you give it too few numbers to process.
>How-To-Repeat:
disklabel -e, and change a partition line to something like:
h: 32 32 unused
and watch it dump core
>Fix:
===================================================================
RCS file: RCS/disklabel.c,v
retrieving revision 1.1
diff -c -r1.1 disklabel.c
*** 1.1 1994/09/20 01:30:34
--- sbin/disklabel/disklabel.c 1994/09/20 01:30:45
***************
*** 1160,1169 ****
}
pp = &lp->d_partitions[part];
#define NXTNUM(n) { \
! cp = tp, tp = word(cp); \
! if (tp == NULL) \
! tp = cp; \
! (n) = atoi(cp); \
}
NXTNUM(v);
--- 1160,1175 ----
}
pp = &lp->d_partitions[part];
#define NXTNUM(n) { \
! if (tp == NULL) { \
! fprintf(stderr, "line %d: too few numeric fields\n", lineno); \
! errors++; \
! break; \
! } else { \
! cp = tp, tp = word(cp); \
! if (tp == NULL) \
! tp = cp; \
! (n) = atoi(cp); \
! } \
}
NXTNUM(v);
>Audit-Trail:
>Unformatted: