From patchwork Wed Jun 3 09:27:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6533571 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8023B9F1CC for ; Wed, 3 Jun 2015 09:32:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A87F420693 for ; Wed, 3 Jun 2015 09:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F6922069F for ; Wed, 3 Jun 2015 09:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753831AbbFCJcL (ORCPT ); Wed, 3 Jun 2015 05:32:11 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:44741 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753327AbbFCJbz (ORCPT ); Wed, 3 Jun 2015 05:31:55 -0400 X-IronPort-AV: E=Sophos;i="5.01,1,1399996800"; d="scan'208";a="96354545" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Jun 2015 17:36:15 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t539UNWi022208 for ; Wed, 3 Jun 2015 17:30:23 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Wed, 3 Jun 2015 17:31:57 +0800 From: Dongsheng Yang To: CC: Dongsheng Yang Subject: [PATCH 2/2] btrfs-progs: qgroup limit: add a check for invalid input of 'T/G/M/K' Date: Wed, 3 Jun 2015 17:27:04 +0800 Message-ID: <1433323624-2194-2-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1433323624-2194-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1433323624-2194-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,GAPPY_SUBJECT, RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a check to error out in the following case: # ./btrfs qgroup limit T /mnt/ Invalid size argument given Without this patch, btrfs-progs would parse the input as 0 and continue. Signed-off-by: Dongsheng Yang --- cmds-qgroup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index 5ea4021..9545a20 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -121,6 +121,9 @@ static int parse_limit(const char *p, unsigned long long *s) return 0; size = strtoull(p, &endptr, 10); + if (p == endptr) + return 0; + switch (*endptr) { case 'T': case 't':