Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
56d5c41f
Commit
56d5c41f
authored
Dec 01, 2020
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utf8: don't allow NUL in decoded strings.
Signed-off-by:
Rusty Russell
<
rusty@rustcorp.com.au
>
parent
b45a3266
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
3 deletions
+5
-3
ccan/utf8/test/run-decode.c
ccan/utf8/test/run-decode.c
+2
-2
ccan/utf8/utf8.c
ccan/utf8/utf8.c
+2
-0
ccan/utf8/utf8.h
ccan/utf8/utf8.h
+1
-1
No files found.
ccan/utf8/test/run-decode.c
View file @
56d5c41f
...
...
@@ -117,7 +117,7 @@ test_unicode_scalar_value(void) {
char
src
[
4
];
/* Unicode scalar value [U+0000, U+007F] */
for
(
ord
=
0x000
0
;
ord
<=
0x007F
;
ord
++
)
{
for
(
ord
=
0x000
1
;
ord
<=
0x007F
;
ord
++
)
{
encode_ord
(
ord
,
1
,
src
);
TEST_UTF8
(
src
,
1
,
ord
?
0
:
ERANGE
);
}
...
...
@@ -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
();
...
...
ccan/utf8/utf8.c
View file @
56d5c41f
...
...
@@ -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
;
...
...
ccan/utf8/utf8.h
View file @
56d5c41f
...
...
@@ -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.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment