summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1994-09-26 04:45:11 +0000
committerpst <pst@FreeBSD.org>1994-09-26 04:45:11 +0000
commitf37e6d1e5de7c658b8eab4fef2567ee7c369fdb4 (patch)
tree2a398f6d712b50c19b8a3ce3a660ce1bd3b3b3cc /sbin
parentd780af9d2a167ec15199c9a4ce807a66de841939 (diff)
downloadFreeBSD-src-f37e6d1e5de7c658b8eab4fef2567ee7c369fdb4.zip
FreeBSD-src-f37e6d1e5de7c658b8eab4fef2567ee7c369fdb4.tar.gz
disklabel will dump core if you give it too few numbers to process
Obtained from: NetBSD misc/490 - John Kohl
Diffstat (limited to 'sbin')
-rw-r--r--sbin/bsdlabel/bsdlabel.c14
-rw-r--r--sbin/disklabel/disklabel.c14
2 files changed, 20 insertions, 8 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 4a29340..0914af2 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -1054,10 +1054,16 @@ getasciilabel(f, lp)
}
pp = &lp->d_partitions[part];
#define NXTNUM(n) { \
- cp = tp, tp = word(cp); \
- if (tp == NULL) \
- tp = cp; \
- (n) = atoi(cp); \
+ 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);
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 4a29340..0914af2 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1054,10 +1054,16 @@ getasciilabel(f, lp)
}
pp = &lp->d_partitions[part];
#define NXTNUM(n) { \
- cp = tp, tp = word(cp); \
- if (tp == NULL) \
- tp = cp; \
- (n) = atoi(cp); \
+ 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);
OpenPOWER on IntegriCloud