From owner-svn-src-stable-7@FreeBSD.ORG Mon Sep 6 15:48:06 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E57F51065694; Mon, 6 Sep 2010 15:48:06 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D42FE8FC0A; Mon, 6 Sep 2010 15:48:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o86Fm6qx054951; Mon, 6 Sep 2010 15:48:06 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o86Fm6QM054949; Mon, 6 Sep 2010 15:48:06 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201009061548.o86Fm6QM054949@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 6 Sep 2010 15:48:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212258 - stable/7/sbin/bsdlabel X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2010 15:48:07 -0000 Author: jh Date: Mon Sep 6 15:48:06 2010 New Revision: 212258 URL: http://svn.freebsd.org/changeset/base/212258 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/7/sbin/bsdlabel/bsdlabel.c Directory Properties: stable/7/sbin/bsdlabel/ (props changed) Modified: stable/7/sbin/bsdlabel/bsdlabel.c ============================================================================== --- stable/7/sbin/bsdlabel/bsdlabel.c Mon Sep 6 13:47:11 2010 (r212257) +++ stable/7/sbin/bsdlabel/bsdlabel.c Mon Sep 6 15:48:06 2010 (r212258) @@ -727,7 +727,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]; @@ -766,11 +766,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")) { @@ -995,7 +999,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; @@ -1031,9 +1035,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,