summaryrefslogtreecommitdiff
path: root/src/libstddjb/slurpn.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-06-23 14:44:54 +0000
committerLaurent Bercot <ska@appnovation.com>2023-06-23 14:44:54 +0000
commit56066894b7d14f71aeba8379f0d6e5961dee733e (patch)
treed2ad93979e0ca63acdadfdc03384d4f1fc106d53 /src/libstddjb/slurpn.c
parent7a9e5888e9b721452869e35b83e74b36844d3cfd (diff)
downloadskalibs-56066894b7d14f71aeba8379f0d6e5961dee733e.tar.xz
Apply fixes suggested by jjk
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb/slurpn.c')
-rw-r--r--src/libstddjb/slurpn.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstddjb/slurpn.c b/src/libstddjb/slurpn.c
index c9c5c11..ee5157f 100644
--- a/src/libstddjb/slurpn.c
+++ b/src/libstddjb/slurpn.c
@@ -16,7 +16,7 @@ int slurpn (int fd, stralloc *sa, size_t max)
for (;;)
{
ssize_t r ;
- size_t n = max && sa->len + N > max ? max - sa->len : N ;
+ size_t n = max && sa->len - sabase + N > max ? max - (sa->len - sabase) : N ;
if (!n) { errno = ENOBUFS ; goto err ; }
if (!stralloc_readyplus(sa, n)) break ;
r = fd_read(fd, sa->s + sa->len, n) ;