diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-06 00:31:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2015-01-06 00:31:40 +0000 |
commit | aa081897ac57658482143f29f4b88b1ebbddede3 (patch) | |
tree | cc16f9e77185652899ed7ea798b56031c69ece80 /src/libunixonacid/unixmessage_receiver_free.c | |
parent | 5b4cf1798bfaf7be1dfaea36614757db80cae23d (diff) | |
download | skalibs-aa081897ac57658482143f29f4b88b1ebbddede3.tar.xz |
- Bugfixes in unixmessage/skaclient (short writes / fd leakage / DoS)v2.1.0.0
- ABI change: unixmessage protocol header is now 6 bytes (was 8)
- API change: skaclient_start(_async) now takes an "options" argument
- version increase to 2.1.0.0
Diffstat (limited to 'src/libunixonacid/unixmessage_receiver_free.c')
-rw-r--r-- | src/libunixonacid/unixmessage_receiver_free.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libunixonacid/unixmessage_receiver_free.c b/src/libunixonacid/unixmessage_receiver_free.c index 353797b..74654d0 100644 --- a/src/libunixonacid/unixmessage_receiver_free.c +++ b/src/libunixonacid/unixmessage_receiver_free.c @@ -1,12 +1,29 @@ /* ISC license. */ #include <skalibs/stralloc.h> +#include <skalibs/djbunix.h> #include <skalibs/unixmessage.h> void unixmessage_receiver_free (unixmessage_receiver_t *b) { + register unsigned int h = b->maindata.len ; b->fd = -1 ; stralloc_free(&b->maindata) ; + h = h != b->mainlen || b->auxdata.len != b->auxlen || cbuffer_len(&b->auxb) ; + if (h) + { + register unsigned int n = b->auxdata.len / sizeof(int) ; + while (n--) fd_close(((int *)b->auxdata.s)[n]) ; + } stralloc_free(&b->auxdata) ; - b->mainlen = b->auxlen = 0 ; + if (h) + { + register unsigned int n = cbuffer_len(&b->auxb) / sizeof(int) ; + if (n) + { + int fds[n] ; + cbuffer_get(&b->auxb, (char *)fds, n * sizeof(int)) ; + while (n--) fd_close(fds[n]) ; + } + } } |