diff options
author | Andreas Schneider <asn@samba.org> | 2014-05-27 09:08:32 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2014-05-27 09:51:33 +0200 |
commit | 98441f8591ff6f57fe26f650b4028ac26cd75527 (patch) | |
tree | 9353e91497041c76a0f589325d2e292e0d99cfaf /src | |
parent | 096c9a7545ab5a406859a67374ca8a1c9d046f28 (diff) | |
download | socket_wrapper-98441f8591ff6f57fe26f650b4028ac26cd75527.tar.gz socket_wrapper-98441f8591ff6f57fe26f650b4028ac26cd75527.tar.xz socket_wrapper-98441f8591ff6f57fe26f650b4028ac26cd75527.zip |
swrap: We need to pass a pointer-pointer to not leak memory.
CID 63533
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 19ac184..7275e73 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3196,14 +3196,14 @@ static int swrap_msghdr_add_socket_info(struct socket_info *si, } static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space); static int swrap_sendmsg_filter_cmsg_socket(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space); static int swrap_sendmsg_filter_cmsghdr(struct msghdr *msg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space) { struct cmsghdr *cmsg; int rc = -1; @@ -3234,7 +3234,7 @@ static int swrap_sendmsg_filter_cmsghdr(struct msghdr *msg, } static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space) { size_t cmspace; @@ -3244,13 +3244,13 @@ static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg, (*cm_data_space) + CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))); - p = realloc(cm_data, cmspace); + p = realloc((*cm_data), cmspace); if (p == NULL) { return -1; } - cm_data = p; + (*cm_data) = p; - p = cm_data + (*cm_data_space); + p = (*cm_data) + (*cm_data_space); *cm_data_space = cmspace; memcpy(p, cmsg, cmsg->cmsg_len); @@ -3259,12 +3259,12 @@ static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg, } static int swrap_sendmsg_filter_cmsg_pktinfo(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space); static int swrap_sendmsg_filter_cmsg_socket(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space) { int rc = -1; @@ -3292,7 +3292,7 @@ static int swrap_sendmsg_filter_cmsg_socket(struct cmsghdr *cmsg, } static int swrap_sendmsg_filter_cmsg_pktinfo(struct cmsghdr *cmsg, - uint8_t *cm_data, + uint8_t **cm_data, size_t *cm_data_space) { (void)cmsg; /* unused */ @@ -3432,7 +3432,7 @@ static ssize_t swrap_sendmsg_before(int fd, uint8_t *cmbuf = NULL; size_t cmlen = 0; - ret = swrap_sendmsg_filter_cmsghdr(msg, cmbuf, &cmlen); + ret = swrap_sendmsg_filter_cmsghdr(msg, &cmbuf, &cmlen); if (ret < 0) { free(cmbuf); return -1; |