diff options
author | chpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-16 15:55:41 +0000 |
---|---|---|
committer | chpe <chpe@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-10-16 15:55:41 +0000 |
commit | ee7e6420e7e2e1c24f902c0a3b21b8e8bece769a (patch) | |
tree | 840edee29a5e9fd217f4fea29a58cbe479f65541 /pcre32_valid_utf32.c | |
parent | eda06e7a8584053a7d81ec394af4781b9c88fb4e (diff) | |
download | pcre-ee7e6420e7e2e1c24f902c0a3b21b8e8bece769a.tar.gz |
pcre32: Reject characters > 0x10ffff in UTF-32 mode
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1088 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre32_valid_utf32.c')
-rw-r--r-- | pcre32_valid_utf32.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pcre32_valid_utf32.c b/pcre32_valid_utf32.c index 799fe50..fc7d550 100644 --- a/pcre32_valid_utf32.c +++ b/pcre32_valid_utf32.c @@ -51,8 +51,6 @@ strings. */ #include "pcre_internal.h" -#define MASK (0x1fffffu) - /************************************************* * Validate a UTF-32 string * *************************************************/ @@ -63,12 +61,13 @@ that subsequent code can assume it is dealing with a valid string. The check can be turned off for maximum performance, but the consequences of supplying an invalid string are then undefined. -From release 8.21 more information about the details of the error are passed +More information about the details of the error are passed back in the returned value: PCRE_UTF32_ERR0 No error PCRE_UTF32_ERR1 Surrogate character -PCRE_UTF32_ERR2 Not allowed character +PCRE_UTF32_ERR2 Disallowed character 0xfffe +PCRE_UTF32_ERR3 Character > 0x10ffff Arguments: string points to the string @@ -94,7 +93,7 @@ if (length < 0) for (p = string; length-- > 0; p++) { - c = *p & MASK; + c = *p & UTF32_MASK; if ((c & 0xfffff800u) != 0xd800u) { @@ -106,6 +105,11 @@ for (p = string; length-- > 0; p++) *erroroffset = p - string; return PCRE_UTF32_ERR2; } + else if (c > 0x10ffffu) + { + *erroroffset = p - string; + return PCRE_UTF32_ERR3; + } } else { |