From unknown Wed Jun 25 10:54:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#28417: ptx does not terminate when matching a zero length sentence regex Resent-From: Julian =?UTF-8?Q?B=C3=BCning?= Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 11 Sep 2017 15:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28417 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 28417@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.150514229121890 (code B ref -1); Mon, 11 Sep 2017 15:05:01 +0000 Received: (at submit) by debbugs.gnu.org; 11 Sep 2017 15:04:51 +0000 Received: from localhost ([127.0.0.1]:33648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drQGZ-0005gy-2Q for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48273) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drQGX-0005gn-MU for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drQGR-000817-RB for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:44434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drQGR-00080f-O4 for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drQGP-0003SS-Ef for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drQGM-0007sr-Al for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:41 -0400 Received: from mail-out-1.itc.rwth-aachen.de ([134.130.5.46]:62659) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drQGM-0007pN-0I for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:38 -0400 X-IronPort-AV: E=Sophos;i="5.42,378,1500933600"; d="scan'208";a="12831241" Received: from rwthex-s3-a.rwth-ad.de ([134.130.26.160]) by mail-in-1.itc.rwth-aachen.de with ESMTP; 11 Sep 2017 17:04:35 +0200 Received: from [137.226.12.58] (137.226.12.58) by rwthex-s3-a.rwth-ad.de (2002:8682:1aa0::8682:1aa0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Mon, 11 Sep 2017 17:04:30 +0200 From: Julian =?UTF-8?Q?B=C3=BCning?= Date: Mon, 11 Sep 2017 17:04:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [137.226.12.58] X-ClientProxiedBy: rwthex-w1-b.rwth-ad.de (2002:8682:1a9d::8682:1a9d) To rwthex-s3-a.rwth-ad.de (2002:8682:1aa0::8682:1aa0) Message-ID: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) 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: -5.0 (-----) observed behavior: $ echo | ptx -S $ & [1] 1000 $ jobs [1]+ Running echo | ptx -S $ & expected behavior: $ echo | ptx -S $ & [1] 1000 [1]+ Done echo | ptx -S $ ptx does not terminate in case the specified sentence regex can be matched but has a match of length zero on input that is non-empty. The following test cases show the same behavior: $ echo | ptx -S ^ $ echo | ptx -S "a*" $ echo | ptx -S "\(\)" $ echo test | ptx -S "\n*" $ echo foo > non_empty; ptx non_empty -S $ ... In ptx.c, find_occurs_in_text() calls re_search() and uses the length of a match (which is falsely assumed to be greater than zero) to advance a cursor through the input. For a match length of zero, the cursor is never advanced. When switching on the results of re_search(), a case 0 could be added. One possible fix would be to then abort with an error message. We found this behavior in version 8.27 and can reproduce it in version 8.25 as well as version 8.28. This behavior was found using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. This research is supported by the European Research Council (ERC) under the EU's Horizon 2020 Research and Innovation Programme grant agreement n. 647295 (SYMBIOSYS). Best regards, Julian From unknown Wed Jun 25 10:54:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#28417: ptx does not terminate when matching a zero length sentence regex Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 13 Sep 2017 21:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28417 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Julian =?UTF-8?Q?B=C3=BCning?= , 28417@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 28417-submit@debbugs.gnu.org id=B28417.150533885422756 (code B ref 28417); Wed, 13 Sep 2017 21:41:02 +0000 Received: (at 28417) by debbugs.gnu.org; 13 Sep 2017 21:40:54 +0000 Received: from localhost ([127.0.0.1]:39016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsFOv-0005uy-Uv for submit@debbugs.gnu.org; Wed, 13 Sep 2017 17:40:54 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:62516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsFOt-0005uk-Nu for 28417@debbugs.gnu.org; Wed, 13 Sep 2017 17:40:52 -0400 Received: from [192.168.101.10] ([91.12.169.143]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MNhBG-1dmE340I7W-0079HU; Wed, 13 Sep 2017 23:40:44 +0200 References: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> From: Bernhard Voelker Message-ID: <9832ef3c-a334-f10d-9d95-3e2d306597f4@bernhard-voelker.de> Date: Wed, 13 Sep 2017 23:40:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> Content-Type: multipart/mixed; boundary="------------0D3C9BD34594914627DBD03F" X-Provags-ID: V03:K0:fgFBYh8bkhBT06vWOfssetByfhDR2J/XAnrQHphiYcESoeZpD0x amQlP82lAQbkxky4A1okHBY8me6LatPyguEx9TXo0E9gNDQqS46NvCxs+wOgRNtp6VAhQjZ ZuNQOytZf/adGzdcqbQQl6nwP7MbIzQBWa/2S099fn5Sz5BdYO5avRoDib/i0blBxhScAUz 4GyAokJM1ZjV+LOJTRO7g== X-UI-Out-Filterresults: notjunk:1;V01:K0:bzBWEjTQhoY=:ZVY0zB8yRLp4EePWzI4lFQ xWFDyUeA2yl79obE4NveoMapRgSWAddhQWXGwCRvj3/YYC5VIxBoyozjGzxN5LwpewyAAhLQA kidCvxSqsL+TiBeXMY3sIudw22asBEjvAtjlqI233sjF6S9hZzxn49Bkioq/OBcCG2Q1xDcMn SVFZTA3eT7bcnYf5ZmWwtI2ajD8eP5h+nP+vVYKaoqrsBqpy8VJvXAN9UXBzCStWVzt+TAu68 EayyHZTytEmjzmPQAiiK9GmQy7d1valSnqoS1DEq1JnCyo/eKBPDJ1krLYE1nJNbbp1Ezsqcw zQ2EGZ1Odg77v3iJ+0MMIHZcbaVmN6/amaNyuxD6O8J0iOP7oI0aiXi8E1y8OCIfPVnk4M3su 7e3SNNczJSAwGwprw3fZxF+U3KHmDlRwOMzK+VHquaHgsTvbdJv/F4GJDmqaAYLMDb3BAL50M CskzdDJzYw9pHKnj+/A/PKZMgpAq6+XCz8tfecYYqvdiU9816kssuOqjzdDZUtJQrN+0K+nkd rsQNVjgSUEJbJy0EtnnKWDjTTi3/TONANKf6B/W51Emwvx2bGbSiz5dxKkEBmuP8+klQfTucI gkk5dQsWZXSknW1UALeRUV66nVcZOxiuauYF/VtK1rnB9ElSglQnSZqdhNqosNy8sQkfk6Bmf 6wJX83w28WUqj0sFQ4LudqeOc+UKMatG5TPJeuuIeaivqiFDyBrsvJh3jPxLx5EFM3X6e80Nd qDpH9aOFyOcG4BSFlcLJdbaOJC5oiO6VaSzjiA== X-Spam-Score: -2.8 (--) 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.8 (--) This is a multi-part message in MIME format. --------------0D3C9BD34594914627DBD03F Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 09/11/2017 05:04 PM, Julian Büning wrote: > observed behavior: > > $ echo | ptx -S $ & > [1] 1000 > $ jobs > [1]+ Running echo | ptx -S $ & > > expected behavior: > > $ echo | ptx -S $ & > [1] 1000 > [1]+ Done echo | ptx -S $ > > ptx does not terminate in case the specified sentence regex can be > matched but has a match of length zero on input that is non-empty. > > The following test cases show the same behavior: > $ echo | ptx -S ^ > $ echo | ptx -S "a*" > $ echo | ptx -S "\(\)" > $ echo test | ptx -S "\n*" > $ echo foo > non_empty; ptx non_empty -S $ > ... > > In ptx.c, find_occurs_in_text() calls re_search() and uses the length of > a match (which is falsely assumed to be greater than zero) to advance a > cursor through the input. For a match length of zero, the cursor is > never advanced. > > When switching on the results of re_search(), a case 0 could be added. > One possible fix would be to then abort with an error message. > > We found this behavior in version 8.27 and can reproduce it in version > 8.25 as well as version 8.28. > > This behavior was found using Symbolic Execution techniques developed in > the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen > University. This research is supported by the European Research Council > (ERC) under the EU's Horizon 2020 Research and Innovation Programme > grant agreement n. 647295 (SYMBIOSYS). Good catch! The attached patch fixes it; please check. Have a nice day, Berny --------------0D3C9BD34594914627DBD03F Content-Type: text/x-patch; name="0001-ptx-avoid-infloop-due-to-zero-length-matches-with-S-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ptx-avoid-infloop-due-to-zero-length-matches-with-S-.pa"; filename*1="tch" >From f082748dbdcab15de50e2e1dc26a7276aec2432c Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 13 Sep 2017 23:37:20 +0200 Subject: [PATCH] ptx: avoid infloop due to zero-length matches with -S regex * src/ptx.c (find_occurs_in_text): Die with an appropriate error diagnostic when the given regular expression returns a match of length 0. * tests/misc/ptx.pl (S-infloop): Add a test. * NEWS (Bug fixes): Mention the fix. Fixes https://bugs.gnu.org/28417 which was detected using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. --- NEWS | 5 +++++ src/ptx.c | 5 +++++ tests/misc/ptx.pl | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/NEWS b/NEWS index 8be22f1..ca36063 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU coreutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + ptx -S no longer infloops for a pattern which returns zero-length matches. + [the bug dates back to the initial implementation] + * Noteworthy changes in release 8.28 (2017-09-01) [stable] diff --git a/src/ptx.c b/src/ptx.c index 2aababf..b7aa107 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -818,6 +818,11 @@ find_occurs_in_text (int file_index) case -1: break; + case 0: + die (EXIT_FAILURE, 0, + _("error: regular expression has a match of length zero: %s"), + quote (context_regex.string)); + default: next_context_start = cursor + context_regs.end[0]; break; diff --git a/tests/misc/ptx.pl b/tests/misc/ptx.pl index d71d065..4d4e1c7 100755 --- a/tests/misc/ptx.pl +++ b/tests/misc/ptx.pl @@ -40,6 +40,12 @@ my @Tests = {OUT=>".xx \"\" \"\" \"foo\" \"\"\n"}], ["format-t", '--format=tex', {IN=>"foo\n"}, {OUT=>"\\xx {}{}{foo}{}{}\n"}], + +# with coreutils-8.28 and earlier, the -S option would infloop with +# matches of zero-length. +["S-infloop", '-S ^', {IN=>"a\n"}, {EXIT=>1}, + {ERR_SUBST=>'s/^.*reg.*ex.*length zero.*$/regexlzero/'}, + {ERR=>"regexlzero\n"}], ); @Tests = triple_test \@Tests; -- 2.1.4 --------------0D3C9BD34594914627DBD03F-- From unknown Wed Jun 25 10:54:36 2025 X-Loop: help-debbugs@gnu.org Subject: bug#28417: ptx does not terminate when matching a zero length sentence regex Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 14 Sep 2017 00:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28417 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bernhard Voelker , Julian =?UTF-8?Q?B=C3=BCning?= , 28417@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 28417-submit@debbugs.gnu.org id=B28417.15053481943838 (code B ref 28417); Thu, 14 Sep 2017 00:17:01 +0000 Received: (at 28417) by debbugs.gnu.org; 14 Sep 2017 00:16:34 +0000 Received: from localhost ([127.0.0.1]:39133 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsHpa-0000zp-0m for submit@debbugs.gnu.org; Wed, 13 Sep 2017 20:16:34 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:50874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsHpY-0000zh-Gx for 28417@debbugs.gnu.org; Wed, 13 Sep 2017 20:16:32 -0400 Received: from localhost.localdomain (c-73-158-116-184.hsd1.ca.comcast.net [73.158.116.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 75ED039D0; Thu, 14 Sep 2017 01:16:30 +0100 (IST) References: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> <9832ef3c-a334-f10d-9d95-3e2d306597f4@bernhard-voelker.de> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <79b93905-1da2-e5d6-c29f-9004c94ae3ad@draigBrady.com> Date: Wed, 13 Sep 2017 17:16:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <9832ef3c-a334-f10d-9d95-3e2d306597f4@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) 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: 0.0 (/) On 13/09/17 14:40, Bernhard Voelker wrote: > On 09/11/2017 05:04 PM, Julian Büning wrote: >> observed behavior: >> >> $ echo | ptx -S $ & >> [1] 1000 >> $ jobs >> [1]+ Running echo | ptx -S $ & >> >> expected behavior: >> >> $ echo | ptx -S $ & >> [1] 1000 >> [1]+ Done echo | ptx -S $ >> >> ptx does not terminate in case the specified sentence regex can be >> matched but has a match of length zero on input that is non-empty. >> >> The following test cases show the same behavior: >> $ echo | ptx -S ^ >> $ echo | ptx -S "a*" >> $ echo | ptx -S "\(\)" >> $ echo test | ptx -S "\n*" >> $ echo foo > non_empty; ptx non_empty -S $ >> ... >> >> In ptx.c, find_occurs_in_text() calls re_search() and uses the length of >> a match (which is falsely assumed to be greater than zero) to advance a >> cursor through the input. For a match length of zero, the cursor is >> never advanced. >> >> When switching on the results of re_search(), a case 0 could be added. >> One possible fix would be to then abort with an error message. >> >> We found this behavior in version 8.27 and can reproduce it in version >> 8.25 as well as version 8.28. >> >> This behavior was found using Symbolic Execution techniques developed in >> the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen >> University. This research is supported by the European Research Council >> (ERC) under the EU's Horizon 2020 Research and Innovation Programme >> grant agreement n. 647295 (SYMBIOSYS). > > Good catch! > The attached patch fixes it; please check. +1 Thanks to both of you From unknown Wed Jun 25 10:54:36 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Julian =?UTF-8?Q?B=C3=BCning?= Subject: bug#28417: closed (Re: bug#28417: ptx does not terminate when matching a zero length sentence regex) Message-ID: References: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> X-Gnu-PR-Message: they-closed 28417 X-Gnu-PR-Package: coreutils Reply-To: 28417@debbugs.gnu.org Date: Thu, 14 Sep 2017 06:39:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1505371142-13797-1" This is a multi-part message in MIME format... ------------=_1505371142-13797-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #28417: ptx does not terminate when matching a zero length sentence regex which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 28417@debbugs.gnu.org. --=20 28417: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28417 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1505371142-13797-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 28417-done) by debbugs.gnu.org; 14 Sep 2017 06:39:00 +0000 Received: from localhost ([127.0.0.1]:39483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsNng-0003aK-0W for submit@debbugs.gnu.org; Thu, 14 Sep 2017 02:39:00 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:62656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsNne-0003a6-DC for 28417-done@debbugs.gnu.org; Thu, 14 Sep 2017 02:38:58 -0400 Received: from [192.168.101.10] ([91.12.169.143]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LcOxi-1dB2YW2HMU-00jnKz; Thu, 14 Sep 2017 08:38:50 +0200 Subject: Re: bug#28417: ptx does not terminate when matching a zero length sentence regex To: =?UTF-8?Q?P=c3=a1draig_Brady?= , =?UTF-8?Q?Julian_B=c3=bcning?= , 28417-done@debbugs.gnu.org References: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> <9832ef3c-a334-f10d-9d95-3e2d306597f4@bernhard-voelker.de> <79b93905-1da2-e5d6-c29f-9004c94ae3ad@draigBrady.com> From: Bernhard Voelker Message-ID: Date: Thu, 14 Sep 2017 08:38:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <79b93905-1da2-e5d6-c29f-9004c94ae3ad@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:OtuvWWfi4FrcUkcI7EKJzi+3t4lcmKltuusVRJR5PRaJOfP2irA 4TOVV8hc1dnFyqinYLTNAbUAKwWOkYi0bvR0Nl/PAcfiUsQQA9pddG0UIuJo8/GmP3hLh2M f5gjEGSxDq83l5CFTGw4vKwdj5+/OQyIu4gYRxOpP1x0O4IQxgQ3CEvxqPojE/s3+rtlVmB Af0lRVwx8/y6ZziNhSYbw== X-UI-Out-Filterresults: notjunk:1;V01:K0:9loWkVigXaw=:AtOLp5K+XT4tnhjCBWnGqL ovWM78LEGbE0vk55cFQ4C9GV9OQ1hYAY/3TxhFenRHm6jQeSu/ZQbLWUjwR2ZQpIEVoVYcZjn fwyOROHebU8XxZILyIAP+uI1GczyMch+vMGSKuywKmFPiE+QDtfVbHLvz17UDiLEeytd0S8/H lg7Nh74vc3C3pgf/rJvfb938+fhCegsjb/6KCujp3oZSh9plvYnKBTQg9yyBNdtXFPUjg8cPx eoIRYF7ofjxZ/nAlS413fu5y1LG+WUz2bIw/yIJx7C6BYRml7Vzh3W/f9MPTxlvlP5gE0QOyK +Uv9IC6kdPfMzlOkgq4ecYZ7UGqvVpo9wmhfYFe0eaoJLY1Bd/mn9BmSCR9hFK04rEZQOYQno KGg4G979dt4rygSLlAPVp3TlPxDfp22+vPC7YORu70UBX6q5WJdgpBzkuNsQOT9ufla+tSPpy YFJLdKfXaLH/fgJaR1R1Gi4ipQIIU30EaLep2V3jRN5NsjN+zbxwTJKil3Ynp68GNEsTm0j5d LvERM0UwPCySBkZgbb+wzVxvH3VfkFGFbILeR6wtqj3m76RELQSiBMpK1gmmwB6lRXHf2Y6z0 nGd4VXaBkow4Ttxy0C5JHTnq0rHI5n+FhYdSosvQx54KHrFoLWY/kGNYSk4I6MZkoNgyGBEtW xl7/l5TjhD1cleeyuwSomgsioJcWGj6Z5Unmu2S/8bvrs8dvaBBUn00XTmqOS2dwTl5t1QNTJ SQGMJuN9b6DbIefCQcx5LzE+ETP2SLRlZjPa6S2T32WVnOh05tU+0PrWWyM= X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 28417-done Cc: Oscar Soria Dustmann , Daniel Schemmel 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.8 (--) On 09/14/2017 02:16 AM, Pádraig Brady wrote: > +1 thanks for the review, pushed. Have a nice day, Berny ------------=_1505371142-13797-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 11 Sep 2017 15:04:51 +0000 Received: from localhost ([127.0.0.1]:33648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drQGZ-0005gy-2Q for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48273) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drQGX-0005gn-MU for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drQGR-000817-RB for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:44434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drQGR-00080f-O4 for submit@debbugs.gnu.org; Mon, 11 Sep 2017 11:04:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drQGP-0003SS-Ef for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drQGM-0007sr-Al for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:41 -0400 Received: from mail-out-1.itc.rwth-aachen.de ([134.130.5.46]:62659) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drQGM-0007pN-0I for bug-coreutils@gnu.org; Mon, 11 Sep 2017 11:04:38 -0400 X-IronPort-AV: E=Sophos;i="5.42,378,1500933600"; d="scan'208";a="12831241" Received: from rwthex-s3-a.rwth-ad.de ([134.130.26.160]) by mail-in-1.itc.rwth-aachen.de with ESMTP; 11 Sep 2017 17:04:35 +0200 Received: from [137.226.12.58] (137.226.12.58) by rwthex-s3-a.rwth-ad.de (2002:8682:1aa0::8682:1aa0) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Mon, 11 Sep 2017 17:04:30 +0200 To: From: =?UTF-8?Q?Julian_B=c3=bcning?= Subject: ptx does not terminate when matching a zero length sentence regex Date: Mon, 11 Sep 2017 17:04:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [137.226.12.58] X-ClientProxiedBy: rwthex-w1-b.rwth-ad.de (2002:8682:1a9d::8682:1a9d) To rwthex-s3-a.rwth-ad.de (2002:8682:1aa0::8682:1aa0) Message-ID: <7561c6c2-9ad9-4f66-98e6-bb20b0665b5c@rwthex-s3-a.rwth-ad.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit Cc: Oscar Soria Dustmann , Daniel Schemmel 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: -5.0 (-----) observed behavior: $ echo | ptx -S $ & [1] 1000 $ jobs [1]+ Running echo | ptx -S $ & expected behavior: $ echo | ptx -S $ & [1] 1000 [1]+ Done echo | ptx -S $ ptx does not terminate in case the specified sentence regex can be matched but has a match of length zero on input that is non-empty. The following test cases show the same behavior: $ echo | ptx -S ^ $ echo | ptx -S "a*" $ echo | ptx -S "\(\)" $ echo test | ptx -S "\n*" $ echo foo > non_empty; ptx non_empty -S $ ... In ptx.c, find_occurs_in_text() calls re_search() and uses the length of a match (which is falsely assumed to be greater than zero) to advance a cursor through the input. For a match length of zero, the cursor is never advanced. When switching on the results of re_search(), a case 0 could be added. One possible fix would be to then abort with an error message. We found this behavior in version 8.27 and can reproduce it in version 8.25 as well as version 8.28. This behavior was found using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. This research is supported by the European Research Council (ERC) under the EU's Horizon 2020 Research and Innovation Programme grant agreement n. 647295 (SYMBIOSYS). Best regards, Julian ------------=_1505371142-13797-1--