{"id":833474,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833474/?format=json","web_url":"http://patchwork.ozlabs.org/project/lede/patch/1509647003-21020-1-git-send-email-philipp@redfish-solutions.com/","project":{"id":54,"url":"http://patchwork.ozlabs.org/api/1.2/projects/54/?format=json","name":"LEDE development","link_name":"lede","list_id":"lede-dev.lists.infradead.org","list_email":"lede-dev@lists.infradead.org","web_url":"http://lede-project.org/","scm_url":"","webscm_url":"http://git.lede-project.org/","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1509647003-21020-1-git-send-email-philipp@redfish-solutions.com>","list_archive_url":null,"date":"2017-11-02T18:23:23","name":"[LEDE-DEV,v1,1/1] uclient-fetch: correct filename w/ multple URLs","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"980855e7fad10eb86bf0f78a9c9f11b9e5eb8179","submitter":{"id":65987,"url":"http://patchwork.ozlabs.org/api/1.2/people/65987/?format=json","name":"Philip Prindeville","email":"philipp@redfish-solutions.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/lede/patch/1509647003-21020-1-git-send-email-philipp@redfish-solutions.com/mbox/","series":[{"id":11560,"url":"http://patchwork.ozlabs.org/api/1.2/series/11560/?format=json","web_url":"http://patchwork.ozlabs.org/project/lede/list/?series=11560","date":"2017-11-02T18:23:23","name":"[LEDE-DEV,v1,1/1] uclient-fetch: correct filename w/ multple URLs","version":1,"mbox":"http://patchwork.ozlabs.org/series/11560/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833474/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833474/checks/","tags":{},"related":[],"headers":{"Return-Path":"<lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (mailfrom)\n\tsmtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133;\n\thelo=bombadil.infradead.org;\n\tenvelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=lists.infradead.org\n\theader.i=@lists.infradead.org header.b=\"qxvMsrRD\"; \n\tdkim-atps=neutral"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n\t[65.50.211.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3ySYQC4VBsz9sNd\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  3 Nov 2017 05:24:19 +1100 (AEDT)","from localhost ([127.0.0.1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eAK9t-0005HV-NW; Thu, 02 Nov 2017 18:24:05 +0000","from mail.redfish-solutions.com ([66.232.79.143])\n\tby bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux))\n\tid 1eAK9p-00056U-HW\n\tfor lede-dev@lists.infradead.org; Thu, 02 Nov 2017 18:24:03 +0000","from ubuntu16.redfish-solutions.com (ubuntu16.redfish-solutions.com\n\t[192.168.1.55]) (authenticated bits=0)\n\tby mail.redfish-solutions.com (8.15.2/8.15.2) with ESMTPSA id\n\tvA2INN7r015215\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=NO); \n\tThu, 2 Nov 2017 12:23:40 -0600"],"DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20170209; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe:\n\tList-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:\n\tDate:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:\n\tList-Owner; bh=dzds8Tiems8D+RuPK/TQQcLJunjI5eKBvnDca+l0e7A=;\n\tb=qxvMsrRD7sN4y5\n\tpdJX5IhS1ZatnTR9TVxoK0gYTx6CeGq17YqEabIUDWh1g0ytw22Xh1+KhTUo2T8h8jl7kfO65hAnH\n\tYQZeZq6yOYIHFz3P4e3FTe6dN+QHr+76QYMpguwJIIavaiQKobm3I/9+gcq2O5yghZNuKpUB5TCGU\n\tHXOvpdUCwpZZnfLFp4y65aOg+UH4oxL8ZDY2YgxPbYke/kGsotcprUXk3cSubXptqGR+/v9Zq2OkH\n\t5AR53SYmBfTm1KKOEB2/ZjjsLaC4DRmWIh+NhqTRXY+3ZoluR9NS2RrsC2qoynFhc+bCQkkL9ouuW\n\t9QbdqH7/CyngW7VmnniQ==;","From":"\"Philip Prindeville\" <philipp@redfish-solutions.com>","To":"lede-dev@lists.infradead.org","Date":"Thu,  2 Nov 2017 12:23:23 -0600","Message-Id":"<1509647003-21020-1-git-send-email-philipp@redfish-solutions.com>","X-Mailer":"git-send-email 2.7.4","X-Scanned-By":"MIMEDefang 2.82 on 192.168.1.3","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20171102_112401_700708_68CBF9C9 ","X-CRM114-Status":"GOOD (  13.08  )","X-Spam-Score":"-1.9 (-)","X-Spam-Report":"SpamAssassin version 3.4.1 on bombadil.infradead.org summary:\n\tContent analysis details:   (-1.9 points)\n\tpts rule name              description\n\t---- ----------------------\n\t--------------------------------------------------\n\t-0.0 SPF_PASS               SPF: sender matches SPF record\n\t-0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay\n\tdomain\n\t-1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n\t[score: 0.0000]","Subject":"[LEDE-DEV] [PATCH v1 1/1] uclient-fetch: correct filename w/\n\tmultple URLs","X-BeenThere":"lede-dev@lists.infradead.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<lede-dev.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/lede-dev/>","List-Post":"<mailto:lede-dev@lists.infradead.org>","List-Help":"<mailto:lede-dev-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/lede-dev>,\n\t<mailto:lede-dev-request@lists.infradead.org?subject=subscribe>","Cc":"Philip Prindeville <philipp@redfish-solutions.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"Lede-dev\" <lede-dev-bounces@lists.infradead.org>","Errors-To":"lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"},"content":"From: Philip Prindeville <philipp@redfish-solutions.com>\n\nWhen uclient-fetch is called with multiple URL's, it derives the\nfirst filename based on the URL. When it then handles the 2nd and\nsubsequent URLs, it assumes that it was called with a -O filename\nargument as the output file, because it tries to overload the\nvariable output_file to mean 2 different things.\n\nThe fix is to use a bool to remember whether we were called with\nan explicit output filename, i.e. with the -O argument, and not\noverload output_file for this purpose.\n\nSigned-off-by: Philip Prindeville <philipp@redfish-solutions.com>\n---\n uclient-fetch.c | 22 ++++++++++++++++++++--\n 1 file changed, 20 insertions(+), 2 deletions(-)","diff":"diff --git a/uclient-fetch.c b/uclient-fetch.c\nindex dff144b22b7b3cd2d5982a615b9c2d68deab5042..fb3ab45935d94dce4f40aeae9bea6d7f7edc1c37 100644\n--- a/uclient-fetch.c\n+++ b/uclient-fetch.c\n@@ -51,6 +51,7 @@ static bool proxy = true;\n static bool default_certs = false;\n static bool no_output;\n static const char *output_file;\n+static bool saw_output_filename = false;\n static int output_fd = -1;\n static int error_ret;\n static off_t out_offset;\n@@ -106,12 +107,12 @@ static int open_output_file(const char *path, uint64_t resume_offset)\n \telse\n \t\tflags = O_WRONLY | O_TRUNC;\n \n-\tif (!cur_resume && !output_file)\n+\tif (!cur_resume && !saw_output_filename)\n \t\tflags |= O_EXCL;\n \n \tflags |= O_CREAT;\n \n-\tif (output_file) {\n+\tif (saw_output_filename) {\n \t\tif (!strcmp(output_file, \"-\")) {\n \t\t\tif (!quiet)\n \t\t\t\tfprintf(stderr, \"Writing to stdout\\n\");\n@@ -500,6 +501,16 @@ static int no_ssl(const char *progname)\n \treturn 1;\n }\n \n+static int too_many_output_files(const char *progname)\n+{\n+\tfprintf(stderr,\n+\t\t\"%s: the -O output_file option can't be used for multiple \"\n+\t\t\"URLs unless its value is \\\"-\\\".\\n\",\n+\t\tprogname);\n+\n+\treturn 1;\n+}\n+\n enum {\n \tL_NO_CHECK_CERTIFICATE,\n \tL_CA_CERTIFICATE,\n@@ -616,6 +627,7 @@ int main(int argc, char **argv)\n \t\t\tbreak;\n \t\tcase 'O':\n \t\t\toutput_file = optarg;\n+\t\t\tsaw_output_filename = true;\n \t\t\tbreak;\n \t\tcase 'P':\n \t\t\tif (chdir(optarg)) {\n@@ -651,6 +663,12 @@ int main(int argc, char **argv)\n \tif (argc < 1)\n \t\treturn usage(progname);\n \n+\t/* doesn't make sense to use -O with multiple URL's unless you're\n+\t * sending them all to stdout...\n+\t */\n+\tif (argc > 1 && saw_output_filename && strcmp(output_file, \"-\"))\n+\t\treturn too_many_output_files(progname);\n+\n \tif (!ssl_ctx) {\n \t\tfor (i = 0; i < argc; i++) {\n \t\t\tif (!strncmp(argv[i], \"https\", 5))\n","prefixes":["LEDE-DEV","v1","1/1"]}