avoid depending on POSIX symbol in code used from plain C functions
authorRich Felker <dalias@aerifal.cx>
Tue, 17 Apr 2012 17:17:01 +0000 (13:17 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 17 Apr 2012 17:17:01 +0000 (13:17 -0400)
src/stdio/__string_read.c

index 5c3728d7fc5fd0b56fd36339fb4beac7cc998798..de002fc19ba49beed1b3962379ed1c5b69116e9e 100644 (file)
@@ -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);