aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-15 21:41:31 +0200
committerDavid Robillard <d@drobilla.net>2020-08-16 13:56:40 +0200
commit6a9db19eb786b51cf1aea232ae7af72b35ac834a (patch)
tree3070cabe6671c13932d923f3ff3a1c81171f885b /src
parent9a847982aa7d4c5f77f89b5d289835b9fb174c5e (diff)
downloadserd-6a9db19eb786b51cf1aea232ae7af72b35ac834a.tar.gz
serd-6a9db19eb786b51cf1aea232ae7af72b35ac834a.tar.bz2
serd-6a9db19eb786b51cf1aea232ae7af72b35ac834a.zip
Fix EOF and null byte handling
This is a bit questionable, but the null byte support is needed for streaming over a socket where some delimiter is required. This caused a bug where serdi would hang forever on corrupt files that contain a null byte. Fix this by consuming the byte, but otherwise behaving as before.
Diffstat (limited to 'src')
-rw-r--r--src/n3.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/n3.c b/src/n3.c
index fad12070..906a0ac4 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1063,7 +1063,7 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot)
}
}
switch (c) {
- case EOF: case '\0': case ')':
+ case EOF: case ')':
return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected object\n");
case '[':
simple = false;
@@ -1166,7 +1166,7 @@ read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool* ate_dot)
do {
read_ws_star(reader);
switch (c = peek_byte(reader)) {
- case EOF: case '\0':
+ case EOF:
return r_err(reader, SERD_ERR_BAD_SYNTAX,
"unexpected end of file\n");
case '.': case ']': case '}':
@@ -1471,7 +1471,10 @@ read_n3_statement(SerdReader* reader)
SerdStatus st = SERD_SUCCESS;
read_ws_star(reader);
switch (peek_byte(reader)) {
- case EOF: case '\0':
+ case '\0':
+ eat_byte_safe(reader, '\0');
+ return SERD_FAILURE;
+ case EOF:
return SERD_FAILURE;
case '@':
if (!fancy_syntax(reader)) {