From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 26 19:00:22 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0300B106566B for ; Tue, 26 Oct 2010 19:00:22 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E56A28FC0C for ; Tue, 26 Oct 2010 19:00:21 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9QJ0LDm010348 for ; Tue, 26 Oct 2010 19:00:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9QJ0LXe010318; Tue, 26 Oct 2010 19:00:21 GMT (envelope-from gnats) Date: Tue, 26 Oct 2010 19:00:21 GMT Message-Id: <201010261900.o9QJ0LXe010318@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Mark Johnston Cc: Subject: Re: bin/143389: [2tb] fdisk(8) cannot handle above 1TB under i386 system. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Mark Johnston List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2010 19:00:22 -0000 The following reply was made to PR bin/143389; it has been noted by GNATS. From: Mark Johnston To: "bug-followup@FreeBSD.org" , "aoyama@peach.ne.jp" Cc: Subject: Re: bin/143389: [2tb] fdisk(8) cannot handle above 1TB under i386 system. Date: Tue, 26 Oct 2010 18:43:42 +0000 I was about to submit a PR about this before I found this one. The problem is that fdisk is using a signed integer to store slice sizes, so attempts to create a slice of size >1TB will result in fdisk using LONG_MAX as the slice size...which ends up corresponding to 1TB on platforms where sizeof(long) =3D=3D 4. The solution is to use an unsigned long instead. We have a patch in our tree for it. Thanks, -Mark diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index 0b2ce7d..89b35f9 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -105,9 +105,9 @@ typedef struct cmd { char cmd; int n_args; struct arg { - char argtype; - int arg_val; - char *arg_str; + char argtype; + unsigned long arg_val; + char *arg_str; } args[MAX_ARGS]; } CMD; =20 @@ -979,7 +979,7 @@ parse_config_line(char *line, CMD *command) if (isalpha(*cp)) command->args[command->n_args].argtype =3D *cp++; end =3D NULL; - command->args[command->n_args].arg_val =3D strtol(cp, &end, 0); + command->args[command->n_args].arg_val =3D strtoul(cp, &end, 0)= ; if (cp =3D=3D end || (!isspace(*end) && *end !=3D '\0')) { char ch; end =3D cp;