50 lines
1.5 KiB
Diff
50 lines
1.5 KiB
Diff
From 5e4861ab4c41b6e000dc1f66225486330b5e5a2d Mon Sep 17 00:00:00 2001
|
|
From: "Arnold D. Robbins" <arnold@skeeve.com>
|
|
Date: Fri, 21 Sep 2018 13:15:38 +0300
|
|
Subject: [PATCH 135/289] Bug fix for trailing backslash in dynamic regexp.
|
|
|
|
---
|
|
ChangeLog | 8 ++++++++
|
|
re.c | 8 +++++++-
|
|
test/ChangeLog | 5 +++++
|
|
test/Makefile.am | 5 ++++-
|
|
test/Makefile.in | 10 +++++++++-
|
|
test/Maketests | 5 +++++
|
|
test/trailbs.awk | 1 +
|
|
test/trailbs.in | 1 +
|
|
test/trailbs.ok | 2 ++
|
|
9 files changed, 42 insertions(+), 3 deletions(-)
|
|
create mode 100644 test/trailbs.awk
|
|
create mode 100644 test/trailbs.in
|
|
create mode 100644 test/trailbs.ok
|
|
|
|
diff --git a/re.c b/re.c
|
|
index eefdfcd7..a693a9ad 100644
|
|
--- a/re.c
|
|
+++ b/re.c
|
|
@@ -112,6 +112,12 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
|
|
(*src == '\\')) {
|
|
c = *++src;
|
|
switch (c) {
|
|
+ case '\0': /* \\ before \0, either dynamic data or real end of string */
|
|
+ if (src >= s + len)
|
|
+ *dest++ = '\\'; // at end of string, will fatal below
|
|
+ else
|
|
+ fatal(_("invalid NUL byte in dynamic regexp"));
|
|
+ break;
|
|
case 'a':
|
|
case 'b':
|
|
case 'f':
|
|
@@ -241,7 +247,7 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal)
|
|
error("%s: /%s/", rerr, buf);
|
|
return NULL;
|
|
}
|
|
- fatal("%s: /%s/", rerr, buf);
|
|
+ fatal("invalid regexp: %s: /%s/", rerr, buf);
|
|
}
|
|
|
|
/* gack. this must be done *after* re_compile_pattern */
|
|
--
|
|
2.19.1
|
|
|