{"id":808162,"url":"http://patchwork.ozlabs.org/api/patches/808162/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/patch/20170831103601.13500-1-christian.storm@siemens.com/","project":{"id":58,"url":"http://patchwork.ozlabs.org/api/projects/58/?format=json","name":"swupdate development","link_name":"swupdate","list_id":"swupdate.googlegroups.com","list_email":"swupdate@googlegroups.com","web_url":"https://github.com/sbabic/swupdate","scm_url":"git://github.com/sbabic/swupdate","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170831103601.13500-1-christian.storm@siemens.com>","list_archive_url":null,"date":"2017-08-31T10:36:01","name":"[v2] core: make cmdline parsing more robust","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ea780e188fde2c960cd55e1cd23071b4af3a5f4c","submitter":{"id":72180,"url":"http://patchwork.ozlabs.org/api/people/72180/?format=json","name":"Storm, Christian","email":"christian.storm@siemens.com"},"delegate":{"id":1693,"url":"http://patchwork.ozlabs.org/api/users/1693/?format=json","username":"sbabic","first_name":"Stefano","last_name":"Babic","email":"sbabic@denx.de"},"mbox":"http://patchwork.ozlabs.org/project/swupdate/patch/20170831103601.13500-1-christian.storm@siemens.com/mbox/","series":[{"id":789,"url":"http://patchwork.ozlabs.org/api/series/789/?format=json","web_url":"http://patchwork.ozlabs.org/project/swupdate/list/?series=789","date":"2017-08-31T10:36:01","name":"[v2] core: make cmdline parsing more robust","version":2,"mbox":"http://patchwork.ozlabs.org/series/789/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808162/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808162/checks/","tags":{},"related":[],"headers":{"Return-Path":"<swupdate+bncBDD6BWV65QPBBFGOT7GQKGQEL27XXDY@googlegroups.com>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=googlegroups.com\n\t(client-ip=2a00:1450:4010:c07::23c;\n\thelo=mail-lf0-x23c.google.com;\n\tenvelope-from=swupdate+bncbdd6bwv65qpbbfgot7gqkgqel27xxdy@googlegroups.com;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=googlegroups.com header.i=@googlegroups.com\n\theader.b=\"pW52qwbK\"; dkim-atps=neutral"],"Received":["from mail-lf0-x23c.google.com (mail-lf0-x23c.google.com\n\t[IPv6:2a00:1450:4010:c07::23c])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjf3Y5CFyz9s2G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 20:38:15 +1000 (AEST)","by mail-lf0-x23c.google.com with SMTP id a126sf128329lfa.15\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 03:38:15 -0700 (PDT)","by 10.46.80.71 with SMTP id v7ls587598ljd.13.gmail;\n\tThu, 31 Aug 2017 03:38:12 -0700 (PDT)","from thoth.sbs.de (thoth.sbs.de. [192.35.17.2])\n\tby gmr-mx.google.com with ESMTPS id 75si5271wma.7.2017.08.31.03.38.12\n\tfor <swupdate@googlegroups.com>\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 31 Aug 2017 03:38:12 -0700 (PDT)","from mail1.siemens.de (mail1.siemens.de [139.23.33.14])\n\tby thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v7VAcC4a032407\n\t(version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK)\n\tfor <swupdate@googlegroups.com>; Thu, 31 Aug 2017 12:38:12 +0200","from MD1KR9XC.ad001.siemens.net ([139.25.69.251])\n\tby mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v7VAcCbx025099;\n\tThu, 31 Aug 2017 12:38:12 +0200"],"ARC-Seal":["i=2; a=rsa-sha256; t=1504175893; cv=pass;\n\td=google.com; s=arc-20160816;\n\tb=0nUmq/JjR9AVGnB9fi8eLH+NdbkPy5Ii156nY9ze6xnKFVnPRswLOZJ2ZQHn/y2lU7\n\t+vQ1u+pYatIzOkfiArc8QMw2Q6lkH9UNwjDDMCwxKPDrNx9JYMaAEJm5e1m7TX/Kyh0U\n\tdU2fEmDDweux/Vx6QnxCPbVNjqn/zUMvJ0/LtwyHkYakkbbIG9ojtUsP6zlIUu5Ru7Cm\n\tKYuMdPZCp8CJdxKdubg8iFs9VyysCP0gmdAKkC2U5G/HcRWujZiJFZt2CBCf43DHuFvC\n\tvVjMj7Odwmryxw7ExcBhr1x4AiC5EoR3HRDoPntgt8Lbi+r/NvfEhTOJ6Ru7P4xCe3yh\n\tfrjw==","i=1; a=rsa-sha256; t=1504175892; cv=none;\n\td=google.com; s=arc-20160816;\n\tb=jY9HnVkG+KdVITnn2U/kt32prHhT8uEbhmo/EhxuxA6NhGPCQOvs9yRHn0M5dl58hb\n\tcAkXIHKup/f2ZNA5wCRVhZI6O5RU5qyuqIg2WnuTskDUIZKOLR1nL3+npj3tasxnDZUn\n\tQbfOv9DpDTu6/niJZCZccYcBiTQF4gGd4+6y6STT2Dj+U8dCTIDCQYrdxaIdLodL6ETd\n\tyLgy6K0dlEgp5h/2qLFVm8Symx2n/emGtQKZWbSRx6myJoRlM8KSYTSdYVPtIG47gTDH\n\tx5iWrBk68HrW7eXCMB8PdGywkpKhafhkG24Lg+wbgIJ5cxTTuKq/m5r8YQm8DQ+9BMHy\n\tmTbQ=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n\t:list-id:mailing-list:precedence:references:in-reply-to:message-id\n\t:date:subject:cc:to:from:arc-authentication-results\n\t:arc-message-signature:mime-version:sender:dkim-signature\n\t:arc-authentication-results;\n\tbh=5Egx635ScbSGUt4UqB1NtOVrtmBDH2WN7s1nVoCodvc=;\n\tb=RCLCd/6AuuQmloDY4yiFWj7n+mlBmWUQ6QEXm3Gm5gv7v32xTxgo38diHprorE5q/Z\n\twbI5rzLi41COeMbEAxbZFd/bARXoQbA/g9Zoa4zEtc8aG+F4Qnv5HZopkNNUV+igAIC7\n\t8jxsVfetFyj23uCsUgZmwUnJOS3ydMgpgzSGGRq4CKU7mK3Vhzt2nx1PBEH8jEdVk4lh\n\tAs2T3sXekRJ7cTGPAiVWFjJM5SNS/kEeK73rX27RezpgWTw7l3suNHB/4WxmHeI3Gkl4\n\tXr5TSx3ontrV4lJji+C+1JEXVXTvZgT9kxPvz0e6H++/LsIQoYTrC5w+w7fII7M7R1mo\n\tHUsw==","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=references:in-reply-to:message-id:date:subject:cc:to:from\n\t:arc-authentication-results;\n\tbh=AD1IB6blnuekrd7enK8p9v7zMj+jc+lTT4SmECwJc10=;\n\tb=kmE2CwQzoGm93KK3JnjGMz9wysfJF7jWhsw1ORSgJe/qNhBGDsFRQnbpdBJ0ms+6HY\n\t1jAwPCUTKP0Ov3bUd5uefCKmB0/msTuoRq7ddbSW3TtOdT6l9R0F9WWamPcq8y2ZAyTX\n\tQd/A30sSJzaj6pdMf5R5o2t/mwXi/DirEAdIpTAEAozRONLXAI68MF10YzUapNND7tyh\n\tcfeFQKd9CoMxroJ/TOj7LnL5DNcv15CQuyjrFX361baBwhUXk4RZxVrjjzCsj1jneeRW\n\t4cPOOWgxHiw91b1fmo+cs7mtGLkCOwYVLJY1Nre7aJd7fOe5yEk+8XikG31cZjFzpJfP\n\t+NUA=="],"ARC-Authentication-Results":["i=2; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.2 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com","i=1; gmr-mx.google.com;\n\tspf=neutral (google.com: 192.35.17.2 is neither permitted nor denied\n\tby best guess record for domain of\n\tchristian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlegroups.com; s=20161025;\n\th=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:x-original-sender:x-original-authentication-results\n\t:precedence:mailing-list:list-id:list-post:list-help:list-archive\n\t:list-subscribe:list-unsubscribe;\n\tbh=5Egx635ScbSGUt4UqB1NtOVrtmBDH2WN7s1nVoCodvc=;\n\tb=pW52qwbKdnDixEUtxfKIkNO+8QFTmYgBzXUTmqgc+T6ZQGxo0V0UmhwBenTbOMv651\n\tpdDyGOfPnomkiPokxRfosyxUzmGd8fktsVl5BWAj+kzovOqPHo8aliqBZ31xmmZbtTfC\n\tUWeDDRQPgDbLDFaOHOrKInHJxNO9ewrK/0/qT3pxAFmF0gF+yCZKVbl7/Uyy2X9o4LrB\n\t2wNUKuFfqFKdzN3kYKvXbhZ0aCIEzocjPtD2gyIK16dAXOMRQrRy8RBbytYzykosHDWQ\n\tVuKtWh6RVyx2yDK+RMgPiKOOYDwgGX0kB2/tqf9DoCBG9YXTvlx0W/WFz5CNvZZm8eDj\n\tUzbQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=sender:x-gm-message-state:mime-version:from:to:cc:subject:date\n\t:message-id:in-reply-to:references:x-original-sender\n\t:x-original-authentication-results:precedence:mailing-list:list-id\n\t:x-spam-checked-in-group:list-post:list-help:list-archive\n\t:list-subscribe:list-unsubscribe;\n\tbh=5Egx635ScbSGUt4UqB1NtOVrtmBDH2WN7s1nVoCodvc=;\n\tb=jPjrhiHbHyqhKfEPi2m/hemCTfxCcGTEz9wc+X8UbZ29M+V6dM6aj83iw7YGOA40mV\n\tSa9DnZSs7vC1lDZvKafSiEf/Ky5ztwVW8Lp697yHiQRgY+WmRY9DANXGtoark0+MpHMT\n\tq4USzcH5fcqsdIl3AcxeKtXAYrP0aqCdS2Xx2Oq9Wu5g8mGwL2tdyDcQTNuDdMhKw3hL\n\tCZ9yODVpG2ZCDCJ9hADCwwnDY2mkIM1PCgaKvpZDdZVb3Sr1OQQt2qYngnf+pIZIKYOM\n\tep9u9CWs4DarixG5gK2C+aT2Niii3f+Ms+Ett1jrPrP/qcJNKoof2F1auiYPYzGoYAR5\n\tsk2g==","Sender":"swupdate@googlegroups.com","X-Gm-Message-State":"AHPjjUiiY7P27tk9L9GPEd2qBjAWSxV0l6KamdPdYrPtg3zuIb1xl1Km\n\tjFpsSdQzzDKFiw==","X-Received":["by 10.25.196.70 with SMTP id u67mr8131lff.14.1504175893203;\n\tThu, 31 Aug 2017 03:38:13 -0700 (PDT)","by 10.46.19.10 with SMTP id 10mr414721ljt.35.1504175892706;\n\tThu, 31 Aug 2017 03:38:12 -0700 (PDT)"],"MIME-Version":"1.0","X-BeenThere":"swupdate@googlegroups.com","Received-SPF":"neutral (google.com: 192.35.17.2 is neither permitted nor\n\tdenied by best guess record for domain of\n\tchristian.storm@siemens.com) client-ip=192.35.17.2; ","From":"Christian Storm <christian.storm@siemens.com>","To":"swupdate@googlegroups.com","Cc":"Christian Storm <christian.storm@siemens.com>","Subject":"[swupdate] [PATCH v2] core: make cmdline parsing more robust","Date":"Thu, 31 Aug 2017 12:36:01 +0200","Message-Id":"<20170831103601.13500-1-christian.storm@siemens.com>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<2a9c51d7-a92a-09b9-27a2-89bee07c5f17@denx.de>","References":"<2a9c51d7-a92a-09b9-27a2-89bee07c5f17@denx.de>","X-Original-Sender":"christian.storm@siemens.com","X-Original-Authentication-Results":"gmr-mx.google.com;       spf=neutral\n\t(google.com: 192.35.17.2 is neither permitted nor denied by best\n\tguess record\n\tfor domain of christian.storm@siemens.com)\n\tsmtp.mailfrom=christian.storm@siemens.com","Content-Type":"text/plain; charset=\"UTF-8\"","Precedence":"list","Mailing-list":"list swupdate@googlegroups.com;\n\tcontact swupdate+owners@googlegroups.com","List-ID":"<swupdate.googlegroups.com>","X-Spam-Checked-In-Group":"swupdate@googlegroups.com","X-Google-Group-Id":"605343134186","List-Post":"<https://groups.google.com/group/swupdate/post>,\n\t<mailto:swupdate@googlegroups.com>","List-Help":"<https://groups.google.com/support/>,\n\t<mailto:swupdate+help@googlegroups.com>","List-Archive":"<https://groups.google.com/group/swupdate","List-Subscribe":"<https://groups.google.com/group/swupdate/subscribe>,\n\t<mailto:swupdate+subscribe@googlegroups.com>","List-Unsubscribe":"<mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n\t<https://groups.google.com/group/swupdate/subscribe>"},"content":"(1) disallow options' values starting with '-' except for\n    downloader, webserver, and suricatta doing their own\n    cmdline parsing. Otherwise, e.g., this command\n    $ swupdate -l -c -i <file>\n    installs <file> instead of checking it due to -l's\n    option value missing.\n(2) abort on superfluous non-option cmdline arguments\n    as SWUpdate doesn't use them, probably an usage error.\n(3) check some sensible combinations with suricatta mode\n\nSigned-off-by: Christian Storm <christian.storm@siemens.com>\n---\n core/swupdate.c | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)","diff":"diff --git a/core/swupdate.c b/core/swupdate.c\nindex b01aadd..1f0ba0d 100644\n--- a/core/swupdate.c\n+++ b/core/swupdate.c\n@@ -599,6 +599,13 @@ int main(int argc, char **argv)\n \t/* Process options with getopt */\n \twhile ((c = getopt_long(argc, argv, main_options,\n \t\t\t\tlong_options, NULL)) != EOF) {\n+\t\tif (optarg && *optarg == '-' && (c != 'd' && c != 'u' && c != 'w')) {\n+\t\t\t/* An option's value starting with '-' is not allowed except\n+\t\t\t * for downloader, webserver, and suricatta doing their own\n+\t\t\t * argv parsing.\n+\t\t\t */\n+\t\t\tc = '?';\n+\t\t}\n \t\tswitch (c) {\n \t\tcase 'v':\n \t\t\tloglevel = TRACELEVEL;\n@@ -680,6 +687,12 @@ int main(int argc, char **argv)\n \t\t}\n \t}\n \n+\tif (optind < argc) {\n+\t\t/* SWUpdate has no non-option arguments, fail on them */\n+\t\tusage(argv[0]);\n+\t\texit(1);\n+\t}\n+\n \t/*\n \t * Parameters are parsed: now performs plausibility\n \t * tests before starting processes and threads\n@@ -698,6 +711,13 @@ int main(int argc, char **argv)\n \t\texit(1);\n \t}\n \n+#ifdef CONFIG_SURICATTA\n+\tif (opt_u && (opt_c || opt_i)) {\n+\t\tfprintf(stderr, \"invalid mode combination with suricatta.\\n\");\n+\t\texit(1);\n+\t}\n+#endif\n+\n \tswupdate_crypto_init();\n \n \tif (strlen(swcfg.globals.publickeyfname)) {\n","prefixes":["v2"]}