diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-13 13:16:13 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-01-13 13:16:13 +0000 |
commit | f3a1fc705ed0fa856c1ce8eab307ec8607f15096 (patch) | |
tree | 791ff6cd711f0dd2a656c3d65c4ff0193c941688 /contrib | |
parent | ab72b000c4b7d72480ca6347334b64d3541e31ad (diff) | |
download | rspamd-f3a1fc705ed0fa856c1ce8eab307ec8607f15096.tar.gz rspamd-f3a1fc705ed0fa856c1ce8eab307ec8607f15096.zip |
[Fix] Fix dealing with `\0` in ucl strings and JSON
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libucl/ucl_chartable.h | 2 | ||||
-rw-r--r-- | contrib/libucl/ucl_emitter.c | 3 | ||||
-rw-r--r-- | contrib/libucl/ucl_util.c | 9 |
3 files changed, 13 insertions, 1 deletions
diff --git a/contrib/libucl/ucl_chartable.h b/contrib/libucl/ucl_chartable.h index db9f02900..043b62689 100644 --- a/contrib/libucl/ucl_chartable.h +++ b/contrib/libucl/ucl_chartable.h @@ -27,7 +27,7 @@ #include "ucl_internal.h" static const unsigned int ucl_chartable[256] = { -UCL_CHARACTER_VALUE_END, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, +UCL_CHARACTER_JSON_UNSAFE|UCL_CHARACTER_VALUE_END|UCL_CHARACTER_UCL_UNSAFE, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_DENIED, UCL_CHARACTER_JSON_UNSAFE|UCL_CHARACTER_UCL_UNSAFE, diff --git a/contrib/libucl/ucl_emitter.c b/contrib/libucl/ucl_emitter.c index d37cdda40..687e6cdae 100644 --- a/contrib/libucl/ucl_emitter.c +++ b/contrib/libucl/ucl_emitter.c @@ -756,6 +756,9 @@ ucl_elt_string_write_json (const char *str, size_t size, func->ucl_emitter_append_len (c, len, func->ud); } switch (*p) { + case '\0': + func->ucl_emitter_append_len ("\\u0000", 6, func->ud); + break; case '\n': func->ucl_emitter_append_len ("\\n", 2, func->ud); break; diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index 5ef83e31b..830aaa14c 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -2244,6 +2244,7 @@ ucl_object_fromstring_common (const char *str, size_t len, enum ucl_string_flags if (ucl_test_character (*p, UCL_CHARACTER_JSON_UNSAFE | UCL_CHARACTER_WHITESPACE_UNSAFE)) { switch (*p) { case '\v': + case '\0': escaped_len += 5; break; case ' ': @@ -2279,6 +2280,14 @@ ucl_object_fromstring_common (const char *str, size_t len, enum ucl_string_flags *d++ = '\\'; *d = 'f'; break; + case '\0': + *d++ = '\\'; + *d++ = 'u'; + *d++ = '0'; + *d++ = '0'; + *d++ = '0'; + *d = '0'; + break; case '\v': *d++ = '\\'; *d++ = 'u'; |