The branch, master has been updated via 5774897 Add README.install - instructions for building and installing. via edaceb0 tests: Fix possible format string attack. via 43a39c5 swrap: Make sure cmbuf is not NULL. via 98441f8 swrap: We need to pass a pointer-pointer to not leak memory. from 096c9a7 tests: Add more tests for socket options.
http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 57748973ae70450c5f875f0ca577bbaed305d9ad Author: Michael Adam <ob...@samba.org> Date: Tue May 27 07:57:20 2014 +0200 Add README.install - instructions for building and installing. Signed-off-by: Michael Adam <ob...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit edaceb0f8fd77cddb78616f3a854accf7175a64b Author: Andreas Schneider <a...@samba.org> Date: Tue May 27 09:35:00 2014 +0200 tests: Fix possible format string attack. Well, there is really not attack on a test but we want to silence Coverity :) CID 17221 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 43a39c5e288423d1be5b5544d8e13847726d7eda Author: Andreas Schneider <a...@samba.org> Date: Tue May 27 09:09:24 2014 +0200 swrap: Make sure cmbuf is not NULL. CID 63532 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> commit 98441f8591ff6f57fe26f650b4028ac26cd75527 Author: Andreas Schneider <a...@samba.org> Date: Tue May 27 09:08:32 2014 +0200 swrap: We need to pass a pointer-pointer to not leak memory. CID 63533 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> ----------------------------------------------------------------------- Summary of changes: README.install | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/socket_wrapper.c | 24 ++++++++-------- tests/test_ioctl.c | 9 ++---- 3 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 README.install Changeset truncated at 500 lines: diff --git a/README.install b/README.install new file mode 100644 index 0000000..e06a951 --- /dev/null +++ b/README.install @@ -0,0 +1,74 @@ +Obtaining the sources +===================== + +Source tarballs for socket_wrapper can be downloaded from + + https://ftp.samba.org/pub/cwrap/ + +The source code repository for socket wrapper is located under + + git://git.samba.org/socket_wrapper.git + +To create a local copy, run + + $ git clone git://git.samba.org/socket_wrapper.git + $ cd socket_wrapper + +Building from sources +===================== + +socket_wrapper uses cmake (www.cmake.org) as build system. + +In a unpacked sources base directory, create a directory to +contain the build results: + + $ mkdir obj + $ cd obj + +Note this target directory can be named arbitrarily. + +Next, run cmake to configure the build, e.g.: + + $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> .. + +or on a 64 bit red hat system: + + $ cmake -DCMAKE_INSTALL_PREFIX=<prefix> -DLIB_SUFFIX=64 .. + +The "<prefix>" should be replaced by the intended installation +target prefix directory, typically /usr or /usr/local. +If the build target directory is no a direct subdirectory +of the source base directory, ".." needs to be replaced +by the relative or absolute path of that directory. + +One can control the build type with "-DCMAKE_BUILD_TYPE=<mode>" +where <mode> can be one of Debug, Release, RelWithDebInfo, and +some more (see cmake.org). The default is RelWithDebInfo. + +Afterward configuring with cmake, run the build with + + $ make + +Unit testing +============ + +In order to support running the test suite after building, +the cmocka unit test framework needs to be installed (cmocka.org), +and you need to specify + + -DUNIT_TESTING=ON + +in the cmake run. After running "make", + + $ make test + +runs the test suite. + +Installing +========== + +socket_wrapper is installed into the prefix directory +after running "cmake" and "make" with + + $ make install + diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 19ac184..b8b1ca3 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; @@ -3441,7 +3441,7 @@ static ssize_t swrap_sendmsg_before(int fd, if (cmlen == 0) { msg->msg_controllen = 0; msg->msg_control = NULL; - } else if (cmlen < msg->msg_controllen) { + } else if (cmlen < msg->msg_controllen && cmbuf != NULL) { memcpy(msg->msg_control, cmbuf, cmlen); msg->msg_controllen = cmlen; } diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c index 1f31c2e..6333720 100644 --- a/tests/test_ioctl.c +++ b/tests/test_ioctl.c @@ -31,9 +31,8 @@ static void setup(void **state) static void teardown(void **state) { - char remove_cmd[256] = {0}; + char remove_cmd[1024] = {0}; const char *swrap_dir = getenv("SOCKET_WRAPPER_DIR"); - char *s; int rc; (void) state; /* unused */ @@ -42,10 +41,8 @@ static void teardown(void **state) return; } - /* Do not use a tainted string in snprintf */ - s = strdup(swrap_dir); - snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", s); - free(s); + strcpy(remove_cmd, "rm -rf "); + strncpy(remove_cmd + 8, swrap_dir, sizeof(remove_cmd) - 9); rc = system(remove_cmd); if (rc < 0) { -- Socket Wrapper Repository