about summary refs log tree commit diff
path: root/safe_u8putstr.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-11-14 16:03:13 +0100
committerLeah Neukirchen <leah@vuxu.org>2018-11-14 16:03:13 +0100
commit188aeac3e1bf03ad087213a9322c23c62b0fea4f (patch)
tree53e1e9a3ac52a5e9eb7bf32ef0590dcccf1e4076 /safe_u8putstr.c
parent2069a0e913167447d84429d09940897b2ffce07e (diff)
downloadmblaze-188aeac3e1bf03ad087213a9322c23c62b0fea4f.tar.gz
mblaze-188aeac3e1bf03ad087213a9322c23c62b0fea4f.tar.xz
mblaze-188aeac3e1bf03ad087213a9322c23c62b0fea4f.zip
safe_u8putstr: handle NUL bytes
These have length 0, but we still want to progress one byte.
Found by duncaen with afl-fuzz.
Diffstat (limited to 'safe_u8putstr.c')
-rw-r--r--safe_u8putstr.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/safe_u8putstr.c b/safe_u8putstr.c
index 31cdb0b..54cd231 100644
--- a/safe_u8putstr.c
+++ b/safe_u8putstr.c
@@ -36,6 +36,9 @@ safe_u8putstr(char *s0, size_t l, FILE *stream)
 			}
 		} else if (c < 32 && 
 		    *s != ' ' && *s != '\t' && *s != '\n' && *s != '\r') {
+			// NUL
+			if (l == 0)
+				l = 1;
 			// C0
 			fputc(0xe2, stream);
 			fputc(0x90, stream);