Skip to content

Commit

Permalink
ccan: update ccan/utf-8 to reject NULs embedded in strings.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Dec 2, 2020
1 parent c29e290 commit ae1a130
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ccan/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CCAN imported from http://ccodearchive.net.

CCAN version: init-2502-gb45a3266
CCAN version: init-2503-g56d5c41f
4 changes: 2 additions & 2 deletions ccan/ccan/utf8/test/run-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test_unicode_scalar_value(void) {
char src[4];

/* Unicode scalar value [U+0000, U+007F] */
for (ord = 0x0000; ord <= 0x007F; ord++) {
for (ord = 0x0001; ord <= 0x007F; ord++) {
encode_ord(ord, 1, src);
TEST_UTF8(src, 1, ord ? 0 : ERANGE);
}
Expand Down Expand Up @@ -255,7 +255,7 @@ test_continuations(void) {
int
main(int argc, char **argv)
{
plan_tests(2190906);
plan_tests(2190906 - 1);
test_unicode_scalar_value();
test_surrogates();
test_non_shortest_form();
Expand Down
2 changes: 2 additions & 0 deletions ccan/ccan/utf8/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ccan/ccan/utf8/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static inline void utf8_state_init(struct utf8_state *utf8_state)
* Otherwise returns true, @utf8_state can be reused without initializeation,
* and sets errno:
* 0: success
* EINVAL: bad encoding.
* EINVAL: bad encoding (including a NUL character).
* EFBIG: not a minimal encoding.
* ERANGE: encoding of invalid character.
*
Expand Down

0 comments on commit ae1a130

Please sign in to comment.