svn commit: r212000 - stable/8/sbin/bsdlabel
Jaakko Heinonen
jh at FreeBSD.org
Mon Aug 30 14:44:23 UTC 2010
Author: jh
Date: Mon Aug 30 14:44:22 2010
New Revision: 212000
URL: http://svn.freebsd.org/changeset/base/212000
Log:
MFC r211342:
- Check that strtoul(3) succeeds to convert the entire string in a few
places.
- In getasciilabel(), set the disk type only when a valid type is given.
PR: bin/86765
Modified:
stable/8/sbin/bsdlabel/bsdlabel.c
Directory Properties:
stable/8/sbin/bsdlabel/ (props changed)
Modified: stable/8/sbin/bsdlabel/bsdlabel.c
==============================================================================
--- stable/8/sbin/bsdlabel/bsdlabel.c Mon Aug 30 14:26:02 2010 (r211999)
+++ stable/8/sbin/bsdlabel/bsdlabel.c Mon Aug 30 14:44:22 2010 (r212000)
@@ -749,7 +749,7 @@ word(char *cp)
static int
getasciilabel(FILE *f, struct disklabel *lp)
{
- char *cp;
+ char *cp, *endp;
const char **cpp;
u_int part;
char *tp, line[BUFSIZ];
@@ -788,11 +788,15 @@ getasciilabel(FILE *f, struct disklabel
}
if (cpp < &dktypenames[DKMAXTYPES])
continue;
- v = strtoul(tp, NULL, 10);
+ errno = 0;
+ v = strtoul(tp, &endp, 10);
+ if (errno != 0 || *endp != '\0')
+ v = DKMAXTYPES;
if (v >= DKMAXTYPES)
fprintf(stderr, "line %d:%s %lu\n", lineno,
"Warning, unknown disk type", v);
- lp->d_type = v;
+ else
+ lp->d_type = v;
continue;
}
if (!strcmp(cp, "flags")) {
@@ -1017,7 +1021,7 @@ static int
getasciipartspec(char *tp, struct disklabel *lp, int part, int lineno)
{
struct partition *pp;
- char *cp;
+ char *cp, *endp;
const char **cpp;
u_long v;
@@ -1053,9 +1057,12 @@ getasciipartspec(char *tp, struct diskla
if (*cpp != NULL) {
pp->p_fstype = cpp - fstypenames;
} else {
- if (isdigit(*cp))
- v = strtoul(cp, NULL, 10);
- else
+ if (isdigit(*cp)) {
+ errno = 0;
+ v = strtoul(cp, &endp, 10);
+ if (errno != 0 || *endp != '\0')
+ v = FSMAXTYPES;
+ } else
v = FSMAXTYPES;
if (v >= FSMAXTYPES) {
fprintf(stderr,
More information about the svn-src-stable-8
mailing list