chiark / gitweb /
util: fix unicode decoding in unquote_first_word()
authorLennart Poettering <lennart@poettering.net>
Fri, 10 Apr 2015 09:56:04 +0000 (11:56 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 06:55:02 +0000 (07:55 +0100)
src/shared/util.c

index ebd4d58..3561573 100644 (file)
@@ -7305,7 +7305,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 return -EINVAL;
                         }
 
-                        if (!GREEDY_REALLOC(s, allocated, sz+2))
+                        if (!GREEDY_REALLOC(s, allocated, sz+7))
                                 return -ENOMEM;
 
                         if (flags & UNQUOTE_CUNESCAPE) {
@@ -7320,7 +7320,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 if (c != 0)
                                         s[sz++] = c; /* normal explicit char */
                                 else
-                                        sz += utf8_encode_unichar(s, u); /* unicode chars we'll encode as utf8 */
+                                        sz += utf8_encode_unichar(s + sz, u); /* unicode chars we'll encode as utf8 */
                         } else
                                 s[sz++] = c;
 
@@ -7352,7 +7352,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 return -EINVAL;
                         }
 
-                        if (!GREEDY_REALLOC(s, allocated, sz+2))
+                        if (!GREEDY_REALLOC(s, allocated, sz+7))
                                 return -ENOMEM;
 
                         if (flags & UNQUOTE_CUNESCAPE) {
@@ -7367,7 +7367,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 if (c != 0)
                                         s[sz++] = c;
                                 else
-                                        sz += utf8_encode_unichar(s, u);
+                                        sz += utf8_encode_unichar(s + sz, u);
                         } else
                                 s[sz++] = c;
 
@@ -7397,7 +7397,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 return -EINVAL;
                         }
 
-                        if (!GREEDY_REALLOC(s, allocated, sz+2))
+                        if (!GREEDY_REALLOC(s, allocated, sz+7))
                                 return -ENOMEM;
 
                         if (flags & UNQUOTE_CUNESCAPE) {
@@ -7412,7 +7412,7 @@ int unquote_first_word(const char **p, char **ret, UnquoteFlags flags) {
                                 if (c != 0)
                                         s[sz++] = c;
                                 else
-                                        sz += utf8_encode_unichar(s, u);
+                                        sz += utf8_encode_unichar(s + sz, u);
                         } else
                                 s[sz++] = c;