From patchwork Wed Mar 20 19:36:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10862531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 130691390 for ; Wed, 20 Mar 2019 19:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8A7E29C39 for ; Wed, 20 Mar 2019 19:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCE0929BFC; Wed, 20 Mar 2019 19:36:38 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 81F0B29C39 for ; Wed, 20 Mar 2019 19:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726538AbfCTTgh (ORCPT ); Wed, 20 Mar 2019 15:36:37 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50164 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbfCTTgh (ORCPT ); Wed, 20 Mar 2019 15:36:37 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2KJXvKv116878; Wed, 20 Mar 2019 19:36:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=oy3CEvx2YdTbJL87yWlZoFxw1ikSOh4dFkANT/7Horc=; b=a5BBYu1vd4RysqvzRccYRoBa5YIhqVUshpbfwszZhE5ZpAnvpcDZq33qT+CuYtvzXFJy hPb6Bqte24bWxSfKDhhTUOxqx0FHe+muFrlqYdI/6p4dtuYqKzHZDldCJE9OAf9rRudE WtSq6OHqOW44UCJZK6iK8YwZ9fnKEf6D4jl4/HjNXVX28VHtEY00Mgr9MEp3efavxU84 66Wa2qKEYQbraAQQkAxvupDpfluOqODtrsfqaWZeIjCOpFDhhdXVPaL3vMMXNms99Fkp C5dNICtgTszohsH78a18mhUiL0CmMkho3HUqpSoczfdQsH1SDyDLkm8lfKepZoQdgan4 rQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2r8rjuvwdg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Mar 2019 19:36:35 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2KJaUYS004163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Mar 2019 19:36:30 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2KJaT8Z001434; Wed, 20 Mar 2019 19:36:29 GMT Received: from localhost (/10.159.247.212) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 20 Mar 2019 12:36:29 -0700 Date: Wed, 20 Mar 2019 12:36:30 -0700 From: "Darrick J. Wong" To: sandeen@sandeen.net Cc: linux-xfs@vger.kernel.org Subject: [PATCH 41/36] xfs_repair: better cli option parameter checking Message-ID: <20190320193630.GE1183@magnolia> References: <155259742281.31886.17157720770696604377.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <155259742281.31886.17157720770696604377.stgit@magnolia> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9201 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=797 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903200142 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 From: Darrick J. Wong For the xfs_repair options that require a parameter, check that the user actually provided one instead of segfaulting. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen --- repair/xfs_repair.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index 2d333d50..9657503f 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -233,10 +233,16 @@ process_args(int argc, char **argv) if (max_mem_specified) do_abort( _("-o bhash option cannot be used with -m option\n")); + if (!val) + do_abort( + _("-o bhash requires a parameter\n")); libxfs_bhash_size = (int)strtol(val, NULL, 0); bhash_option_used = 1; break; case AG_STRIDE: + if (!val) + do_abort( + _("-o ag_stride requires a parameter\n")); ag_stride = (int)strtol(val, NULL, 0); break; case FORCE_GEO: @@ -247,6 +253,9 @@ process_args(int argc, char **argv) force_geo = 1; break; case PHASE2_THREADS: + if (!val) + do_abort( + _("-o phase2_threads requires a parameter\n")); phase2_threads = (int)strtol(val, NULL, 0); break; default: @@ -262,6 +271,9 @@ process_args(int argc, char **argv) switch (getsubopt(&p, c_opts, &val)) { case CONVERT_LAZY_COUNT: + if (!val) + do_abort( + _("-c lazycount requires a parameter\n")); lazy_count = (int)strtol(val, NULL, 0); convert_lazy_count = 1; break;