From patchwork Mon Dec 1 19:28:25 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 11643 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 5F870DDDCA for ; Tue, 2 Dec 2008 06:28:45 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbYLAT2d (ORCPT ); Mon, 1 Dec 2008 14:28:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753187AbYLAT2d (ORCPT ); Mon, 1 Dec 2008 14:28:33 -0500 Received: from fg-out-1718.google.com ([72.14.220.152]:41796 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752453AbYLAT2b (ORCPT ); Mon, 1 Dec 2008 14:28:31 -0500 Received: by fg-out-1718.google.com with SMTP id 19so1892008fgg.17 for ; Mon, 01 Dec 2008 11:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=s53NrHJ8GjJF5MU7FbEhqvopfiXkGpDqlPgfGduI3OE=; b=HrXzHQ0ip2bWR9w1j3QWMkXr+kv7pav6o84Gs7KRsmueZafsVyhaWx0aoj8Q8AIcRN fXJxt1H/5D+4mRFUGExeQz08NUElhNHXKkPiqf0neF5MNsIxvNhyD1zHmE6xmlFiI6fS LgB3cQzX/2sJ4BNzNEn+9Lt7uppdIHEykugp8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=T/d4WSgeyISIIshw5wPSztVoIGGL5SGfbJR0c2yAZZyc4FVuBAyXEnNKgDT2no1kVj w4VGq3T+MrD/zMZ+uyw5bpqMkBGY5httrs4xGUL3KVUcv27KK0o3dOiCeGQJSV+aCJUj Bnpu0OEqocLcPJ/BWcvOKiOGl8D5XKR9Jc9mY= Received: by 10.181.199.6 with SMTP id b6mr4022935bkq.137.1228159709883; Mon, 01 Dec 2008 11:28:29 -0800 (PST) Received: from ?192.168.1.117? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id a1sm9098448ugf.26.2008.12.01.11.28.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 01 Dec 2008 11:28:28 -0800 (PST) Message-ID: <49343AD9.4020606@gmail.com> Date: Mon, 01 Dec 2008 14:28:25 -0500 From: roel kluin User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: davidsen@tmr.com CC: tytso@mit.edu, adilger@sun.com, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] ext3, ext4: do_split() fix loop, with obvious unsigned wrap Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Fix loop, with obvious unsigned wrap Signed-off-by: Roel Kluin --- -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 3e5edc9..b0dcfb3 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1188,7 +1188,7 @@ static struct ext3_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, /* Split the existing block in the middle, size-wise */ size = 0; move = 0; - for (i = count-1; i >= 0; i--) { + for (i = count; i--; ) { /* is more than half of this entry in 2nd half of the block? */ if (size + map[i].size/2 > blocksize/2) break; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 63adcb7..34232c6 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1198,7 +1198,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, /* Split the existing block in the middle, size-wise */ size = 0; move = 0; - for (i = count-1; i >= 0; i--) { + for (i = count; i--; ) { /* is more than half of this entry in 2nd half of the block? */ if (size + map[i].size/2 > blocksize/2) break;