]> git.ozlabs.org Git - ccan/blobdiff - ccan/utf8/utf8.c
utf8: don't allow NUL in decoded strings.
[ccan] / ccan / utf8 / utf8.c
index 346d2d95b72f98dc2d1a32ce7884091ccbd200d5..cb18041a5d35cb9f2486388e828d3cd6f77d19c0 100644 (file)
@@ -63,6 +63,8 @@ bool utf8_decode(struct utf8_state *utf8_state, char c)
                /* First character in sequence. */
                if (((unsigned char)c & 0x80) == 0) {
                        /* ASCII, easy. */
+                       if (c == 0)
+                               goto bad_encoding;
                        utf8_state->total_len = 1;
                        utf8_state->c = c;
                        goto finished_decoding;