From owner-freebsd-bugs@FreeBSD.ORG Wed Jun 6 03:20:03 2007 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1AC5716A468 for ; Wed, 6 Jun 2007 03:20:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id DA0DA13C448 for ; Wed, 6 Jun 2007 03:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l563K2kt047473 for ; Wed, 6 Jun 2007 03:20:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l563K2OA047472; Wed, 6 Jun 2007 03:20:02 GMT (envelope-from gnats) Resent-Date: Wed, 6 Jun 2007 03:20:02 GMT Resent-Message-Id: <200706060320.l563K2OA047472@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Staffan Ulfberg Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3A2CE16A421 for ; Wed, 6 Jun 2007 03:14:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.freebsd.org (Postfix) with ESMTP id 2C8FA13C46A for ; Wed, 6 Jun 2007 03:14:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l563EdVV085563 for ; Wed, 6 Jun 2007 03:14:39 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id l563EcGX085455; Wed, 6 Jun 2007 03:14:39 GMT (envelope-from nobody) Message-Id: <200706060314.l563EcGX085455@www.freebsd.org> Date: Wed, 6 Jun 2007 03:14:39 GMT From: Staffan Ulfberg To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: bin/113399: growfs has singed int overflow in printf X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jun 2007 03:20:03 -0000 >Number: 113399 >Category: bin >Synopsis: growfs has singed int overflow in printf >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jun 06 03:20:02 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Staffan Ulfberg >Release: 6.2-STABLE >Organization: Harmonicode AB >Environment: FreeBSD multivac.fatburen.org 6.2-STABLE FreeBSD 6.2-STABLE #0: Sun May 6 19:09:39 CEST 2007 staffanu@multivac.fatburen.org:/usr/obj/usr/src/sys/MULTIVAC i386 >Description: When growfs prints out the cylinder numbers that are used for suber-block backups, it prints negative numbers for cylinders that are larger than 2^31. The utility still works (at least it did for me when growing a 1.3 TB file system to 1.5 TB), but it looks quite worrying. I for one did not proceed to actually run the tool (after having tested with -N) until I had checked the source code to see that the problem only appears in the printout. >How-To-Repeat: Run growfs on a file system larger than 1 TB. >Fix: multivac# diff -u growfs.c.orig growfs.c --- growfs.c.orig Wed Jun 6 05:13:05 2007 +++ growfs.c Wed Jun 6 05:13:44 2007 @@ -259,8 +259,8 @@ */ for (cylno = osblock.fs_ncg; cylno < sblock.fs_ncg; cylno++) { initcg(cylno, utime, fso, Nflag); - j = sprintf(tmpbuf, " %d%s", - (int)fsbtodb(&sblock, cgsblock(&sblock, cylno)), + j = sprintf(tmpbuf, " %jd%s", + (intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cylno)), cylno < (sblock.fs_ncg-1) ? "," : "" ); if (i + j >= width) { printf("\n"); >Release-Note: >Audit-Trail: >Unformatted: