From patchwork Wed Nov 18 19:18:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 11915681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEC13C6379D for ; Wed, 18 Nov 2020 19:19:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FAF32220B for ; Wed, 18 Nov 2020 19:19:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=osandov-com.20150623.gappssmtp.com header.i=@osandov-com.20150623.gappssmtp.com header.b="P+TeFcfj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbgKRTTN (ORCPT ); Wed, 18 Nov 2020 14:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727257AbgKRTTN (ORCPT ); Wed, 18 Nov 2020 14:19:13 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16228C0613D6 for ; Wed, 18 Nov 2020 11:19:12 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id v21so1874907pgi.2 for ; Wed, 18 Nov 2020 11:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JYWJRMKbUtIw9wn+lQz4lq4B6TtPUTRJxtYsp8IVtUs=; b=P+TeFcfjPu71imXbMcYBwDzoqWey+0zWEIUwcvdfflet/BxNWCaSv6kLmRFW/E9yyl 6eKq9y57pzSB292X++K1y2HCqg70YkCI6TKrc8GWvBc3LZvzVDkawgBzpdXNt/i1j9fn pCYAcoJy/B2WLKOTLoHJeNUmSMEbJb2EWY/+vV1s4xNM7pPkSGVs0Zh5k6CP9qAGr08u UQdil4LvrkKYhg8oKpOVkfRh5yu0pWN/bGHqa2PvGxZmVia+1necn5ik3ryvhnr3YZnI QKkX/5VANN4wUr27qECdPYkiaogoIK4S48a5q/FLnnu2Ld6hvlEW9FSR9t1qS1Qfggch oKqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JYWJRMKbUtIw9wn+lQz4lq4B6TtPUTRJxtYsp8IVtUs=; b=oxH4YmZbsQva7Z8q6/X5qPzTLlYZLoe4JC+Pau1eUPNQd8xJO1zPDtgyn9R3GxZPHW J5zIhOpVRnxc/CTcsGv64+Laf2ZH7+30ope410nyuOzGQZCit9s6UEC432mqR7TDcsUf u1VHh7mCMCDYK8GueDZhvB8fGRPpL/eBLBJESw2cKD9S3YFouIya1Bc1cTX9DLpoAxLm XeGlZO2qJ2YqKeZwEZlll1IipBQqJl/Vw6/zdOi7jm2bc4uFFzpN+tNR5HkmkW9PhDCG Xfwbawfb6eU1DD53rMb+ogideFaMsqrBHbEWZN1/EBNBhFcyMoLwBDhRz0Z0Nmbo9fjH tICw== X-Gm-Message-State: AOAM531RsYMwMre58r9a6G4ClPpyb32AtEnTuYBXDQWzuNIUxGS3gVt+ AyYQAKm2lwHKhQVgzYabQAK5X4uBjI55Fg== X-Google-Smtp-Source: ABdhPJzIDUz8a5nuon9F5p++Ob7zX7/TXpDTPdqKVfXzc+qVORDrdOD8p/eqjNeY4cxMYQ+Qa45OvQ== X-Received: by 2002:a63:2045:: with SMTP id r5mr9243326pgm.6.1605727151031; Wed, 18 Nov 2020 11:19:11 -0800 (PST) Received: from relinquished.tfbnw.net ([2620:10d:c090:400::5:8b43]) by smtp.gmail.com with ESMTPSA id l9sm3197221pjy.10.2020.11.18.11.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:19:09 -0800 (PST) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v2 01/13] btrfs-progs: send: fix crash on unknown option Date: Wed, 18 Nov 2020 11:18:44 -0800 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Omar Sandoval The long options array for send is missing the zero terminator, so unknown options result in a crash: # btrfs send --foo Segmentation fault (core dumped) Signed-off-by: Omar Sandoval --- cmds/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds/send.c b/cmds/send.c index b8e3ba12..3bfc69f5 100644 --- a/cmds/send.c +++ b/cmds/send.c @@ -496,7 +496,8 @@ static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv) static const struct option long_options[] = { { "verbose", no_argument, NULL, 'v' }, { "quiet", no_argument, NULL, 'q' }, - { "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA } + { "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA }, + { NULL, 0, NULL, 0 } }; int c = getopt_long(argc, argv, "vqec:f:i:p:", long_options, NULL);