[PATCH] Consolidate & clean up fd-passing
Ralph Böhme
rb at sernet.de
Mon Jan 5 06:53:36 MST 2015
On Thu, Jan 01, 2015 at 06:48:49PM +0100, Volker Lendecke wrote:
> Hi!
>
> Recently I've been playing with fd-passing a bit more. The CMSG style
> macros mandated by standards are really, really ugly to use in my
> opinion. Attached find a patchset that consolidates these macros from
> unix_msg and aio_fork (along with minor cleanups), making them much
> easier to use (at least IMHO).
>
> Review&push appreciated!
looks good. I'd add NULL checks in two places and the last commit
misses your signed-off, but other then that
reviewed-by: me
-Ralph
From 371aea2c7130e038932c5f3125f41e5b8ddacdf5 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Thu, 1 Jan 2015 00:04:06 +0100
Subject: [PATCH] fixup: check for NULL pointers
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source3/lib/msghdr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/lib/msghdr.c b/source3/lib/msghdr.c
index 9ed1444..82f7ca7 100644
--- a/source3/lib/msghdr.c
+++ b/source3/lib/msghdr.c
@@ -40,7 +40,7 @@ ssize_t msghdr_prep_fds(struct msghdr *msg, uint8_t *buf, size_t bufsize,
if (num_fds > INT8_MAX) {
return -1;
}
- if (cmsg_space > bufsize) {
+ if ((msg == NULL) || (cmsg_space > bufsize)) {
return cmsg_space;
}
@@ -167,7 +167,7 @@ size_t msghdr_extract_fds(struct msghdr *msg, int *fds, size_t fds_size)
num_fds = (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int);
- if ((num_fds != 0) && (fds_size >= num_fds)) {
+ if ((num_fds != 0) && (fds != NULL) && (fds_size >= num_fds)) {
memcpy(fds, CMSG_DATA(cmsg), num_fds * sizeof(int));
}
--
1.9.3
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
More information about the samba-technical
mailing list