diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-11-13 17:26:42 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2015-11-13 17:26:42 +0000 |
commit | ca720a4ecf24b397b11980c58ebfb5fa3738c967 (patch) | |
tree | c59d05108acbe2d9b836207c633db96ecf8b3625 | |
parent | 1100f040d85c6d37bb08975240978a9598d8b3e6 (diff) | |
download | pcre2-ca720a4ecf24b397b11980c58ebfb5fa3738c967.tar.gz |
Paranoid check in regcomp() for bad error code from pcre2_compile().
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@432 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/pcre2posix.c | 7 |
2 files changed, 8 insertions, 1 deletions
@@ -299,6 +299,8 @@ regcomp() error instead of waiting for regexec() to pick it up. 88. In pcre2_substitute(), ensure that CRLF is not split when it is a valid newline sequence. +89. Paranoid check in regcomp() for bad error code from pcre2_compile(). + Version 10.20 30-June-2015 -------------------------- diff --git a/src/pcre2posix.c b/src/pcre2posix.c index 61a0f58..dc36e45 100644 --- a/src/pcre2posix.c +++ b/src/pcre2posix.c @@ -217,8 +217,13 @@ preg->re_erroffset = erroffset; if (preg->re_pcre2_code == NULL) { unsigned int i; - if (errorcode < 0) return REG_BADPAT; /* UTF error */ + + /* A negative value is a UTF error; otherwise all error codes are greater + than COMPILE_ERROR_BASE, but check, just in case. */ + + if (errorcode < COMPILE_ERROR_BASE) return REG_BADPAT; errorcode -= COMPILE_ERROR_BASE; + if (errorcode < (int)(sizeof(eint1)/sizeof(const int))) return eint1[errorcode]; for (i = 0; i < sizeof(eint2)/(2*sizeof(const int)); i += 2) |