summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-09-28 01:42:39 +0200
committerMichael Adam <obnox@samba.org>2014-09-30 16:36:09 +0200
commit698e8a235740d4cedc5635b9f64da16cb3cb1f01 (patch)
treefa05efa44ac2393f9d156e861487b9e5e19ee6d2
parent2795bdfd9ffd5c69402543d6f5f22b53e9d357a6 (diff)
downloadsamba-698e8a235740d4cedc5635b9f64da16cb3cb1f01.tar.gz
s3:unix_msg: add "close_fds" exit point to unix_msg_recv()
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
-rw-r--r--source3/lib/unix_msg/unix_msg.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c
index 01554a22ae5..ad415ddc010 100644
--- a/source3/lib/unix_msg/unix_msg.c
+++ b/source3/lib/unix_msg/unix_msg.c
@@ -985,9 +985,9 @@ static void unix_msg_recv(struct unix_dgram_ctx *dgram_ctx,
uint64_t cookie;
if (buflen < sizeof(cookie)) {
- close_fd_array(fds, num_fds);
- return;
+ goto close_fds;
}
+
memcpy(&cookie, buf, sizeof(cookie));
buf += sizeof(cookie);
@@ -999,8 +999,7 @@ static void unix_msg_recv(struct unix_dgram_ctx *dgram_ctx,
}
if (buflen < sizeof(hdr)) {
- close_fd_array(fds, num_fds);
- return;
+ goto close_fds;
}
memcpy(&hdr, buf, sizeof(hdr));
@@ -1023,8 +1022,7 @@ static void unix_msg_recv(struct unix_dgram_ctx *dgram_ctx,
if (msg == NULL) {
msg = malloc(offsetof(struct unix_msg, buf) + hdr.msglen);
if (msg == NULL) {
- close_fd_array(fds, num_fds);
- return;
+ goto close_fds;
}
*msg = (struct unix_msg) {
.msglen = hdr.msglen,
@@ -1037,21 +1035,23 @@ static void unix_msg_recv(struct unix_dgram_ctx *dgram_ctx,
space = msg->msglen - msg->received;
if (buflen > space) {
- close_fd_array(fds, num_fds);
- return;
+ goto close_fds;
}
memcpy(msg->buf + msg->received, buf, buflen);
msg->received += buflen;
if (msg->received < msg->msglen) {
- close_fd_array(fds, num_fds);
- return;
+ goto close_fds;
}
DLIST_REMOVE(ctx->msgs, msg);
ctx->recv_callback(ctx, msg->buf, msg->msglen, fds, num_fds, ctx->private_data);
free(msg);
+ return;
+
+close_fds:
+ close_fd_array(fds, num_fds);
}
int unix_msg_free(struct unix_msg_ctx *ctx)