skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 978416c7e201d8261f9ecf512169f384261b1a9a
parent b59ce39f9779cf4b1ad423783b6a532f94a8e880
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri,  9 Jan 2015 17:00:34 +0000

 Bugfix: unixmessage_put was recording the wrong number of fds

Diffstat:
Msrc/libunixonacid/unixmessage_put.c | 4++--
Msrc/libunixonacid/unixmessage_sender_flush.c | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c @@ -49,7 +49,7 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha static int reserve_and_copy (unixmessage_sender_t *b, unsigned int len, int const *fds, unsigned int nfds, unsigned char const *bits) { - diuint cur = { .left = b->data.len, .right = b->fds.len } ; + diuint cur = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; if (len > UNIXMESSAGE_MAXSIZE || nfds > UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ; if (!genalloc_readyplus(diuint, &b->offsets, 1) @@ -57,7 +57,7 @@ static int reserve_and_copy (unixmessage_sender_t *b, unsigned int len, int cons || !stralloc_readyplus(&b->data, len)) return 0 ; if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits)) return 0 ; - b->fds.len += nfds * sizeof(int) ; + genalloc_setlen(int, &b->fds, cur.right + nfds) ; byte_copy(b->offsets.s + b->offsets.len, sizeof(diuint), (char const *)&cur) ; b->offsets.len += sizeof(diuint) ; return 1 ; diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c @@ -26,7 +26,7 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) { - diuint last = { .left = (uint32)b->data.len, .right = genalloc_len(int, &b->fds) } ; + diuint last = { .left = b->data.len, .right = genalloc_len(int, &b->fds) } ; diuint *offsets = genalloc_s(diuint, &b->offsets) ; unsigned int n = genalloc_len(diuint, &b->offsets) ; register int r ;