From 8b57a81577980e4b440addaa8f2bbed454be2a59 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 17 Apr 2012 13:17:01 -0400 Subject: [PATCH] avoid depending on POSIX symbol in code used from plain C functions --- src/stdio/__string_read.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.25.1