diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-05 08:16:34 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-05 08:16:34 -0800 |
commit | 0c364bffbc87487ea32ec49d000cb84164fe6135 (patch) | |
tree | 14e5b15fc363fbf97707d5ecfa5afa9efa6b3b8e /utf8.c | |
parent | 5725cb7635e93a0c09d6af97881c75f907edd225 (diff) | |
download | txr-0c364bffbc87487ea32ec49d000cb84164fe6135.tar.gz txr-0c364bffbc87487ea32ec49d000cb84164fe6135.tar.bz2 txr-0c364bffbc87487ea32ec49d000cb84164fe6135.zip |
parser: security: UTF-8 and NUL handling in literals.
A null byte in regex and string literals is being processed as
a #\nul instead of correctly turning into #\pnul. Bad UTF-8 is
not being rejected.
* parser.l (REGCHAR, LITCHAR): Use utf8_from_buffer to
properly convert yytext using its true length, rather than
utf8_from which assumes a null-terminated string. Thus
null bytes (including the case of a yytext being single NUL)
are handled properly. Check that the result is exactly one
character (null-terminated buffer, two characters wide).
* utf8.c (utf8_from): Unused function removed.
* utf8.h (utf8_from): Declaration removed.
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 6 |
1 files changed, 0 insertions, 6 deletions
@@ -139,12 +139,6 @@ size_t utf8_from_buf(wchar_t *wdst, const unsigned char *src, size_t nbytes) return nchar; } -size_t utf8_from(wchar_t *wdst, const char *src) -{ - size_t nbytes = strlen(src); - return utf8_from_buf(wdst, coerce(const unsigned char *, src), nbytes); -} - size_t utf8_to_buf(unsigned char *dst, const wchar_t *wsrc, int null_term) { size_t nbyte = 0; |