From patchwork Mon Jul 4 00:11:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 9211509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A3E060752 for ; Mon, 4 Jul 2016 00:12:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E62BF2793B for ; Mon, 4 Jul 2016 00:12:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9C8227F99; Mon, 4 Jul 2016 00:12:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CF442793B for ; Mon, 4 Jul 2016 00:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932249AbcGDAMW (ORCPT ); Sun, 3 Jul 2016 20:12:22 -0400 Received: from imap.thunk.org ([74.207.234.97]:60728 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932236AbcGDAMW (ORCPT ); Sun, 3 Jul 2016 20:12:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=Message-Id:Date:Subject:Cc:To:From; bh=dRmoxBimzBLh/rgVK8XL87jO98eCjQw8SptCqHAGvE8=; b=i/ue9AAZAs6lE28XCauvEdDjdI9rVo+NU4SczaC7A70mzSm7cYuXzvBjftWyE/NzDxjr8ngyGAK413SARYKzd6a5nJIqWQQTJiU1qU0Es5bbnYxdYBjd/whaom4wqCyd24qmW7xz5JwHdl+tQm9pnYdKDDpRcTExaE/eHG8C0J8=; Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.84_2) (envelope-from ) id 1bJrUm-0004Gb-J3; Mon, 04 Jul 2016 00:12:16 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id 7C6EF8286EE; Sun, 3 Jul 2016 20:12:15 -0400 (EDT) From: Theodore Ts'o To: fstests@vger.kernel.org Cc: Ext4 Developers List , Theodore Ts'o , Eric Sandeen Subject: [PATCH] quota: fix generic/244 on 32-bit platforms Date: Sun, 3 Jul 2016 20:11:56 -0400 Message-Id: <1467591116-16880-1-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 2.5.0 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The test program src/test-nextquota.c relies on atoi() to convert a string to an *unsigned* int. If the string represents an integer which is greater than INT_MAX, it is undefined how atoi(3) works, and it turns out that: uint id = atoi("2147483649"); results in id == 2147483649 on x86_64, and id == 2147483647 on a 32-bit x86 platform. So use strtoul(3) instead, which is portable and technically correct. Signed-off-by: Theodore Ts'o Cc: Eric Sandeen Reviewed-by: Eric Sandeen --- src/test-nextquota.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test-nextquota.c b/src/test-nextquota.c index a2bbad9..6eec1f9 100644 --- a/src/test-nextquota.c +++ b/src/test-nextquota.c @@ -74,6 +74,7 @@ int main(int argc, char *argv[]) int verbose = 0; uint id = 0, idflag = 0; char *device = NULL; + char *tmp; struct nextdqblk dqb; struct fs_disk_quota xqb; @@ -92,7 +93,11 @@ int main(int argc, char *argv[]) typeflag++; break; case 'i': - id = atoi(optarg); + id = (int) strtoul(optarg, &tmp, 0); + if (*tmp) { + fprintf(stderr, "Bad id: %s\n", optarg); + exit(1); + } idflag++; break; case 'd':