diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-10-21 00:41:20 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-10-21 00:41:20 +0000 |
commit | af1ae27abbb0e80f59f4848c4fe7ccaee3690382 (patch) | |
tree | 88e1a22ede68f44ed1e76e9d91896f0ec41b59f0 | |
parent | 45923c08b00ccdfd888caf6d2b555a137c563988 (diff) | |
download | skalibs-af1ae27abbb0e80f59f4848c4fe7ccaee3690382.tar.xz |
Bugfix: getlnmax(sep) needs to include the terminating byte when found
-rw-r--r-- | src/libstddjb/getlnmax.c | 4 | ||||
-rw-r--r-- | src/libstddjb/getlnmaxsep.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libstddjb/getlnmax.c b/src/libstddjb/getlnmax.c index 7f7d679..a9e6146 100644 --- a/src/libstddjb/getlnmax.c +++ b/src/libstddjb/getlnmax.c @@ -19,8 +19,8 @@ int getlnmax (buffer *b, char *d, size_t max, size_t *w, char sep) if (len > max - *w) len = max - *w ; pos = siovec_bytechr(v, 2, sep) ; if (pos > len) pos = len ; - r = pos < len ; - buffer_getnofill(b, d + *w, pos + r) ; *w += pos ; + r = pos < len ; pos += r ; + buffer_getnofill(b, d + *w, pos) ; *w += pos ; if (*w >= max) return (errno = ERANGE, -1) ; if (r) return 1 ; r = buffer_fill(b) ; diff --git a/src/libstddjb/getlnmaxsep.c b/src/libstddjb/getlnmaxsep.c index 7b7dc0e..5ea1017 100644 --- a/src/libstddjb/getlnmaxsep.c +++ b/src/libstddjb/getlnmaxsep.c @@ -19,8 +19,8 @@ int getlnmaxsep (buffer *b, char *d, size_t max, size_t *w, char const *sep, siz if (len > max - *w) len = max - *w ; pos = siovec_bytein(v, 2, sep, seplen) ; if (pos > len) pos = len ; - r = pos < len ; - buffer_getnofill(b, d + *w, pos + r) ; *w += pos ; + r = pos < len ; pos += r ; + buffer_getnofill(b, d + *w, pos) ; *w += pos ; if (*w >= max) return (errno = ERANGE, -1) ; if (r) return 1 ; r = buffer_fill(b) ; |