aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2017-09-13 23:37:20 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2017-09-14 07:50:27 +0200
commit97c5045435f15c2bc984cc05bbfdca897bbdd284 (patch)
tree973fcb938eb53e5e865d3148ad34cbc4f3601f2c /src
parentmaint: post-release administrivia (diff)
downloadcoreutils-97c5045435f15c2bc984cc05bbfdca897bbdd284.tar.gz
coreutils-97c5045435f15c2bc984cc05bbfdca897bbdd284.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ptx.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ptx.c b/src/ptx.c
index 2aababff6..b7aa1079b 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;