diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-04-17 13:17:01 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-04-17 13:17:01 -0400 |
commit | 8b57a81577980e4b440addaa8f2bbed454be2a59 (patch) | |
tree | d13e2a51ee0d7b5e9137d8e2e17e64d68f2c4234 /src/stdio/__string_read.c | |
parent | 03de77f5210addfd2ca2b35137152edfe2ab70be (diff) | |
download | musl-8b57a81577980e4b440addaa8f2bbed454be2a59.tar.gz musl-8b57a81577980e4b440addaa8f2bbed454be2a59.tar.xz musl-8b57a81577980e4b440addaa8f2bbed454be2a59.zip |
avoid depending on POSIX symbol in code used from plain C functions
Diffstat (limited to 'src/stdio/__string_read.c')
-rw-r--r-- | src/stdio/__string_read.c | 4 |
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); |