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: 11915699 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=unavailable 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 BB50EC56202 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 4FCCE22227 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 S1727263AbgKRTTN (ORCPT ); Wed, 18 Nov 2020 14:19:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727252AbgKRTTM (ORCPT ); Wed, 18 Nov 2020 14:19:12 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BDA9C0613D4 for ; Wed, 18 Nov 2020 11:19:11 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id q34so1847910pgb.11 for ; Wed, 18 Nov 2020 11:19:11 -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=WaIWGcRqVNFDokXwPiUj33lYcpUljj9HiLs7Ykzbi+7jxG0Avr+YyM8gJ3QH51T6jF qdh1ZBf+tEDJvNLpMVMLu40SBwysNT7j27Tl4agK1G59M0GclPdU7fEpWTzADrHw7sW2 fUOc7F0eQvr4oNXF5k42QBxPy6LRjtNVb/gFHkZagzTNhJLI8Q9L3JsFUw6gYC3z21gv I/FdoxzXRyVfaT2AX88VzIXIp8juOeBHWxRKHECCfo3JFKPoS9+Lsp/OxoUcS5iC0Rtw FZjStg1vRY4slN7YwNgIEXT5xfWwDyod/k5f1om3Tuqhb9SlITHnB4WyBHIjl7erfi3t LZcA== X-Gm-Message-State: AOAM530eCprhTm3LIeXy9v6QULGRkpdBDVTHT+VAuz+/4SyQnlMktkOG dLmgjkdd1sFohJyW49bpQccezg== 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-fsdevel@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);