From patchwork Tue Aug 22 21:12:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9916189 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 A8F9C600C5 for ; Tue, 22 Aug 2017 21:12:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CAAF288B8 for ; Tue, 22 Aug 2017 21:12:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9155F28932; Tue, 22 Aug 2017 21:12:50 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 0B5DF288B8 for ; Tue, 22 Aug 2017 21:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751362AbdHVVMt (ORCPT ); Tue, 22 Aug 2017 17:12:49 -0400 Received: from sandeen.net ([63.231.237.45]:34258 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbdHVVMt (ORCPT ); Tue, 22 Aug 2017 17:12:49 -0400 Received: from [10.0.0.4] (liberator [10.0.0.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id 3566087A; Tue, 22 Aug 2017 16:11:27 -0500 (CDT) Subject: [PATCH 1/3] libxfs: handle 0 blocksize or sectorsize in cvtnum To: Eric Sandeen , linux-xfs References: <2b5a5742-5343-671f-8b89-9d1dc9841c17@redhat.com> From: Eric Sandeen Message-ID: <2e0acf4a-a863-8304-65d3-5027368c69e2@sandeen.net> Date: Tue, 22 Aug 2017 16:12:48 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <2b5a5742-5343-671f-8b89-9d1dc9841c17@redhat.com> Content-Language: en-US Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Blocksize and sectorsize are unique in that they must be provided, unlike every other suffix which can be calculated from constants. Nothing protects against unspecified block & sector size, so catch it if it happens and return a parsing error. Signed-off-by: Eric Sandeen --- -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" 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/libxcmd/input.c b/libxcmd/input.c index 7a69dc1..7b86225 100644 --- a/libxcmd/input.c +++ b/libxcmd/input.c @@ -330,8 +330,12 @@ cvtnum( c = tolower(*sp); switch (c) { case 'b': + if (!blocksize) + return -1LL; return i * blocksize; case 's': + if (!sectorsize) + return -1LL; return i * sectorsize; case 'k': return KILOBYTES(i);