about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/stdio/__string_read.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/stdio/__string_read.c b/src/stdio/__string_read.c
index 5c3728d7..de002fc1 100644
--- a/src/stdio/__string_read.c
+++ b/src/stdio/__string_read.c
@@ -3,7 +3,9 @@
 size_t __string_read(FILE *f, unsigned char *buf, size_t len)
 {
 	char *src = f->cookie;
-	size_t k = strnlen(src, len+256);
+	size_t k = len+256;
+	char *end = memchr(src, 0, k);
+	if (end) k = end-src;
 	if (k < len) len = k;
 	memcpy(buf, src, len);
 	f->rpos = (void *)(src+len);