From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id A7CA51F4B4 for ; Thu, 1 Oct 2020 03:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730537AbgJADqZ (ORCPT ); Wed, 30 Sep 2020 23:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730415AbgJADqY (ORCPT ); Wed, 30 Sep 2020 23:46:24 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5CAC0613D2 for ; Wed, 30 Sep 2020 20:46:24 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id q9so1445943wmj.2 for ; Wed, 30 Sep 2020 20:46:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=vQqBZ6n4yoJvFdWDcAg0rtHyyez4I2x9VidEL47I2n4=; b=Kr4JwqetAlYtgVWFanZqv9EpNUc97EhDNzjVXhKAHCkOlto23JJKZF8ygTOhf+8NQ7 aH/hGZB0BxGK8Axu/KyzwuGotAVAJHBYUFted64liC1FYBHYugadi9+U5ypy0IjDKvUV SBsr5hRRdRfCE0xnIzq9RaAYubSSIMKQqpw1UEaaeor0bxjVEWqNaw0vpFMtEkdu5Yqc uGpUIwhr5iC/3XmX0sfIQitbjEBjOcDNRHB4IVsimSjpDjzMo6kL/Sf/8TSmO+lfQ66F rvoHTXB/1VHqFPsGrqvO1MJCr85TcEHKaL5iNGsJf14jLSybuCuynPTK7bf6/h2kbVcf ownA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=vQqBZ6n4yoJvFdWDcAg0rtHyyez4I2x9VidEL47I2n4=; b=ZctP1VYdzNJ3/0+QyeI+228K2Pj6KrSugliHNmnhQckbft++Ymd616ANLQZ6+H/6SY P+EFuVkKNtC1Xl8wQUVG7aK8pKTd1Qi7NMTb0YAiMczYUSsL8gdrXuWqsAjr/Dm7DnJT ZuEgg1ZWLTyahfePcvzYBBJAmhQZcJ31ZhmUvtplROi1GrcoyLrMQnBnntOSm2qZMeJw MZyWDjkN+gJxsS2EIfZBXmGTSkdIyNxaWol7aix6cpfXU2YF10++0x32tP4MM8fo6njV +ZK6jOIMoi6pzCef6HFz/y3O6bSZ5f/erLTGnZpPCBuij7XRfVZMHot7Zf0FYlvSDkWH 7Fbg== X-Gm-Message-State: AOAM533a2Il0vQipeUwgF4BZn+KAhDNKKlz+sg5JvD2GA8SbbGXPX0Zd E5ZeZjC8fqsFj3SqC+9R6Hm+VsDV6H8= X-Google-Smtp-Source: ABdhPJzx07zChtSLHvKBf00c0/MHyp+pEOyMG6s9qeaAf/OIABYF4zq5dfMjF7ApHeap50u03OzPYw== X-Received: by 2002:a05:600c:216:: with SMTP id 22mr5790426wmi.149.1601523982627; Wed, 30 Sep 2020 20:46:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h76sm6949272wme.10.2020.09.30.20.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 20:46:22 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Sean Barag via GitGitGadget" Date: Thu, 01 Oct 2020 03:46:14 +0000 Subject: [PATCH v3 5/7] clone: validate --origin option before use Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Derrick Stolee , Jeff King , Eric Sunshine , Taylor Blau , Sean Barag , Andrei Rybak , Sean Barag , Sean Barag Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Sean Barag Providing a bad origin name to `git clone` currently reports an 'invalid refspec' error instead of a more explicit message explaining that the `--origin` option was malformed. This behavior dates back to since 8434c2f1 (Build in clone, 2008-04-27). Reintroduce validation for the provided `--origin` option, but notably _don't_ include a multi-level check (e.g. "foo/bar") that was present in the original `git-clone.sh`. `git remote` allows multi-level remote names since at least 46220ca100 (remote.c: Fix overtight refspec validation, 2008-03-20), so that appears to be the desired behavior. Helped-by: Junio C Hamano Helped-by: Derrick Stolee Helped-by: Jeff King Signed-off-by: Sean Barag --- builtin/clone.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/clone.c b/builtin/clone.c index a76dacd988..bd67ff7b01 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1011,6 +1011,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (!option_origin) option_origin = "origin"; + if (!valid_remote_name(option_origin)) + die(_("'%s' is not a valid remote name"), option_origin); + repo_name = argv[0]; path = get_repo_path(repo_name, &is_bundle); -- gitgitgadget