summaryrefslogtreecommitdiff
path: root/src/libunixonacid/unixmessage_receive.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-12-14 09:40:02 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-12-14 09:40:02 +0000
commit6a5f838c03ed16a335c6cb11e923aa95fa56217b (patch)
treeabea6252f4aa40859e2d250362c733078c81d4ae /src/libunixonacid/unixmessage_receive.c
parent2edb33dbe99c7b7e30904823da867f497a6acf65 (diff)
downloadskalibs-6a5f838c03ed16a335c6cb11e923aa95fa56217b.tar.xz
unixmessage_receive: don't read more than 1 message at a time
Diffstat (limited to 'src/libunixonacid/unixmessage_receive.c')
-rw-r--r--src/libunixonacid/unixmessage_receive.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c
index bcba24b..a86ae10 100644
--- a/src/libunixonacid/unixmessage_receive.c
+++ b/src/libunixonacid/unixmessage_receive.c
@@ -92,8 +92,12 @@ int unixmessage_receive (unixmessage_receiver_t *b, unixmessage_t *m)
for (;;)
{
register int r ;
- b->maindata.len += cbuffer_get(&b->mainb, b->maindata.s + b->maindata.len, cbuffer_len(&b->mainb)) ;
- b->auxdata.len += cbuffer_get(&b->auxb, b->auxdata.s + b->auxdata.len, cbuffer_len(&b->auxb)) ;
+ register unsigned int n = cbuffer_len(&b->mainb) ;
+ if (n > b->mainlen - b->maindata.len) n = b->mainlen - b->maindata.len ;
+ b->maindata.len += cbuffer_get(&b->mainb, b->maindata.s + b->maindata.len, n) ;
+ n = cbuffer_len(&b->auxb) ;
+ if (n > b->auxlen - b->auxdata.len) n = b->auxlen - b->auxdata.len ;
+ b->auxdata.len += cbuffer_get(&b->auxb, b->auxdata.s + b->auxdata.len, n) ;
if (b->maindata.len == b->mainlen && b->auxdata.len == b->auxlen) break ;
r = sanitize_read(unixmessage_receiver_fill(b)) ;
if (r <= 0) return r ;