From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 17 21:26:40 2021 Received: (at submit) by debbugs.gnu.org; 18 Apr 2021 01:26:40 +0000 Received: from localhost ([127.0.0.1]:44977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXwCu-0005Aq-KM for submit@debbugs.gnu.org; Sat, 17 Apr 2021 21:26:40 -0400 Received: from lists.gnu.org ([209.51.188.17]:59730) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lXwCs-0005Ah-LN for submit@debbugs.gnu.org; Sat, 17 Apr 2021 21:26:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXwCs-0005To-F4 for bug-coreutils@gnu.org; Sat, 17 Apr 2021 21:26:38 -0400 Received: from dormouse.elm.relay.mailchannels.net ([23.83.212.50]:23738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXwCo-0000UM-DK for bug-coreutils@gnu.org; Sat, 17 Apr 2021 21:26:38 -0400 X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B2972341ADA for ; Sun, 18 Apr 2021 01:26:32 +0000 (UTC) Received: from pdx1-sub0-mail-a9.g.dreamhost.com (100-96-133-89.trex.outbound.svc.cluster.local [100.96.133.89]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 522C834205D for ; Sun, 18 Apr 2021 01:26:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jidanni@jidanni.org Received: from pdx1-sub0-mail-a9.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.133.89 (trex/6.1.1); Sun, 18 Apr 2021 01:26:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jidanni@jidanni.org X-MailChannels-Auth-Id: dreamhost X-Inform-Attack: 535f1add51c5068e_1618709192545_1948648849 X-MC-Loop-Signature: 1618709192545:1532917617 X-MC-Ingress-Time: 1618709192545 Received: from pdx1-sub0-mail-a9.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTP id 0D1B886747 for ; Sat, 17 Apr 2021 18:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=jidanni.org; bh=RCDtdwiky3EGob0Ilx oYimUhrKE=; b=b2HkQrcEsTzfbJ6shJwFfDLBZgY2QUSWMuROf7kRZJhle6XclR x96bQeJnvamLFutXu1zHi/q9wjmdiGa2LFbKAuQKHL9WySico68gHpMXaFXsMWUK N1GOD+VWM+7J4jddma7WGFGDXnFh90FfV1veXg1ypyc8GwVPZH9VJoCUc= Received: from jidanni.org (114-41-19-154.dynamic-ip.hinet.net [114.41.19.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by pdx1-sub0-mail-a9.g.dreamhost.com (Postfix) with ESMTPSA id C7733861BE for ; Sat, 17 Apr 2021 18:26:31 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a9 From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: bug-coreutils@gnu.org Subject: Additional seq outlandish example: seq 0 dangers Date: Sun, 18 Apr 2021 09:26:28 +0800 Message-ID: <87zgxw2xiz.5.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=23.83.212.50; envelope-from=jidanni@jidanni.org; helo=dormouse.elm.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On (info "(coreutils) seq invocation") we read Be careful when using =E2=80=98seq=E2=80=99 with outlandish values: ot= herwise you may... Here's another 'fun/sad/DDOS yourself' example you might add: One day I wrote a Makefile, m: seq 0 9|sed s/$$/=E8=99=9F.html/|xargs make but before using it, I though I'll just test with one item, m: seq 0 |sed s/$$/=E8=99=9F.html/|xargs make well of course... as seq prints nothing here, this triggered a massive ever growing recursive loop... Yes, all my fault for picking 0. I'll pick 1 next time. P.S., perhaps document how to get seq to cough up just "0". One way I found was: $ seq 0 1 0 0 From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 18 02:30:03 2021 Received: (at 47859) by debbugs.gnu.org; 18 Apr 2021 06:30:03 +0000 Received: from localhost ([127.0.0.1]:45134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lY0wV-0004Md-Ca for submit@debbugs.gnu.org; Sun, 18 Apr 2021 02:30:03 -0400 Received: from mailgw1.uni-kl.de ([131.246.120.220]:49969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lY0wT-0004Lm-C3 for 47859@debbugs.gnu.org; Sun, 18 Apr 2021 02:30:02 -0400 Received: from sushi.unix-ag.uni-kl.de (sushi.unix-ag.uni-kl.de [IPv6:2001:638:208:ef34:0:ff:fe00:65]) by mailgw1.uni-kl.de (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 13I6TxW9183351 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <47859@debbugs.gnu.org>; Sun, 18 Apr 2021 08:29:59 +0200 Received: from sushi.unix-ag.uni-kl.de (ip6-localhost [IPv6:::1]) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id 13I6TxaV021376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for <47859@debbugs.gnu.org>; Sun, 18 Apr 2021 08:29:59 +0200 Received: (from auerswal@localhost) by sushi.unix-ag.uni-kl.de (8.14.4/8.14.4/Submit) id 13I6TxKc021374 for 47859@debbugs.gnu.org; Sun, 18 Apr 2021 08:29:59 +0200 Date: Sun, 18 Apr 2021 08:29:59 +0200 From: Erik Auerswald To: 47859@debbugs.gnu.org Subject: Re: bug#47859: Additional seq outlandish example: seq 0 dangers Message-ID: <20210418062959.GA17723@unix-ag.uni-kl.de> References: <87zgxw2xiz.5.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87zgxw2xiz.5.fsf@jidanni.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, hits=-1, tests=ALL_TRUSTED=-1 X-Spam-Score: (-1) X-Spam-Flag: NO X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 47859 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, On Sun, Apr 18, 2021 at 09:26:28AM +0800, 積丹尼 Dan Jacobson wrote: > On (info "(coreutils) seq invocation") we read > Be careful when using ‘seq’ with outlandish values: otherwise you > may... > > Here's another 'fun/sad/DDOS yourself' example you might add: > > One day I wrote a Makefile, > m: > seq 0 9|sed s/$$/號.html/|xargs make > but before using it, I though I'll just test with one item, > m: > seq 0 |sed s/$$/號.html/|xargs make > well of course... as seq prints nothing here, > this triggered a massive ever growing recursive loop... > > Yes, all my fault for picking 0. I'll pick 1 next time. > > P.S., perhaps document how to get seq to cough up just "0". One way I > found was: > $ seq 0 1 0 > 0 I would like to add more information to this bug report with the intent of helping everybody involved now or in the future. A slighly simpler method to make 'seq' print just '0' is: $ seq 0 0 0 This is documented, but more generally, e.g., in 'seq --help': $ seq --help Usage: seq [OPTION]... LAST or: seq [OPTION]... FIRST LAST or: seq [OPTION]... FIRST INCREMENT LAST Print numbers from FIRST to LAST, in steps of INCREMENT. [...] If FIRST or INCREMENT is omitted, it defaults to 1. [...] [...] Thus, 'seq 0' is the same as 'seq 1 1 0' and 'seq 0 0' is the same as 'seq 0 1 0'. The default value of '1' for omitted parameters affects other values, too, not just '0': $ seq -1 $ seq -1 -1 -1 $ seq -100000 $ seq -100000 -100000 -100000 When "FIRST" and "LAST" are the same, any valid "INCREMENT" value results in 'seq' printing just one value, not just the default of '1': $ seq 0 200 0 0 $ seq 0 -200 0 0 $ seq 0 0 0 seq: invalid Zero increment value: ‘0’ Try 'seq --help' for more information. Thus IMHO a possible addition to the documentation should probably not just single out 'seq 0', but mention any number smaller than the default value for "FIRST" of '1'. HTH, HAND Erik -- Inside every large problem is a small problem struggling to get out. -- Hoare's Law of Large Problems From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 19 02:23:56 2021 Received: (at 47859) by debbugs.gnu.org; 19 Apr 2021 06:23:56 +0000 Received: from localhost ([127.0.0.1]:48226 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYNK8-0002eO-25 for submit@debbugs.gnu.org; Mon, 19 Apr 2021 02:23:56 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:60751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lYNK6-0002eB-Eb for 47859@debbugs.gnu.org; Mon, 19 Apr 2021 02:23:55 -0400 Received: from [192.168.101.10] ([91.12.165.121]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MtfRv-1lnAVl1kfn-00v616; Mon, 19 Apr 2021 08:23:42 +0200 Subject: Re: bug#47859: Additional seq outlandish example: seq 0 dangers To: =?UTF-8?B?56mN5Li55bC8IERhbiBKYWNvYnNvbg==?= , 47859@debbugs.gnu.org References: <87zgxw2xiz.5.fsf@jidanni.org> From: Bernhard Voelker Message-ID: <8d4e3c5a-ad7f-9b3a-64e2-8a6a6fccf5da@bernhard-voelker.de> Date: Mon, 19 Apr 2021 08:23:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <87zgxw2xiz.5.fsf@jidanni.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:IhlbgxTtpKxOV5pYVjFCEmal/U0SVTJH5ag+aQg4bCrTprGny85 KrFe2jAK8lXE1h2ELXTXjNE0HihbFnyuWi/enH3K4X4KUgiXgeMx4uWPoIA5di4DGGotMav nLVWR5leyt7wna6aaDLSG8zHceThm4sS8uRH3JwWg+AQDYnHgn2PQSbLvi/wDl2nLhWmZGX hGP1no5l+i5hnMokSiCCg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:brvRGPn1Gkw=:SXJO6oRcZnDqICKT3z511l vlzBzwYdGSqJeXkhuyBIy/Xh7A20uU4wGmeYQocOCAsxiqIWt3TCko1BjS0tyOs1A7skTQpCC OtKH3X8halVIldPwNMO09CnKDdrtQ+IBEl7VXVVwlQxuGZL0UwbfilNndXRQSyw+2+43MR6jR ZRnKcT/+RyCkY4msewO/OKavJFv2EK//6ctGIn/kZo47n96RF5u0zY53EoOv7GxtImjOM2vis 3DVVVkp9Or1wfoiNWFMns6cyKelgWaIig1dC+0SI5oB7csmsmFqA9v8Z2IfNqiW0jKcGGxac7 wrwGwazKyw2rxb533Zn1jKP23vclV7/ie0JLVpk+XKBZNHN2PnzQFF6O+NG2mR+vbxLqfAk6t Y911pYroJ5nWpLEC8bRu8qTZ4VWz2e8CcmWxt7Ow9CL9bjyywxB1i55TYwDA0/lJwx0Z5I8qE Upt423gId08Ms0IIrA8WSTtbdTZltTdRvdOcvqpriT1rK4YD3w/7Nl9xmnE51AaIIPuNCoHu4 5kDyQgg1YNutdruUrBViT0= X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 47859 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 4/18/21 3:26 AM, 積丹尼 Dan Jacobson wrote: > Here's another 'fun/sad/DDOS yourself' example you might add: > > One day I wrote a Makefile, > m: > seq 0 9|sed s/$$/號.html/|xargs make > but before using it, I though I'll just test with one item, > m: > seq 0 |sed s/$$/號.html/|xargs make > well of course... as seq prints nothing here, > this triggered a massive ever growing recursive loop... > > Yes, all my fault for picking 0. I'll pick 1 next time. Besides the main discussion about seq(1), I want to add that xargs(1) [0] is often run most usefully with: -r, --no-run-if-empty if there are no arguments, then do not run COMMAND; if this option is not given, COMMAND will be run at least once Portability hint: Unfortunately, the -r option is not required by POSIX. At least, the BSD family (FreeBSD [1], NetBSD [2], OpenBSD [3]) has it; on Solaris [4], only the '1g' variant [5] has it. Not sure about other implementations. [0] https://www.gnu.org/software/findutils/manual/html_node/find_html/xargs-options.html [1] https://www.freebsd.org/cgi/man.cgi?xargs [2] https://man.netbsd.org/xargs.1 [3] https://man.openbsd.org/xargs.1 [4] https://docs.oracle.com/cd/E88353_01/html/E37839/xargs-1.html [5] https://docs.oracle.com/cd/E88353_01/html/E37839/xargs-1g.html Have a nice day, Berny