[SCM] Socket Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Fri Apr 25 06:28:03 MDT 2014


The branch, master has been updated
       via  fb8afa1 swrap: Use the loaded libc open() directly.
       via  08ffcf5 echo_srv: Fix possible resouce leaks on error in socket_dup().
       via  1d7993b tests: Fix use of tainted string in test_ioctl.
       via  7f10395 cmake: Fix policy check.
       via  f79b7fa cmake: Install cmake config in the correct directory.
      from  d242129 echo_srv: Improve reopening low fds.

http://gitweb.samba.org/?p=socket_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fb8afa1fb23135a8b7635f3f04d69a6c24626319
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 25 08:37:37 2014 +0200

    swrap: Use the loaded libc open() directly.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 08ffcf57e38ca19d9a7535d61951dbd292f39bdb
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Apr 14 21:57:15 2014 +0200

    echo_srv: Fix possible resouce leaks on error in socket_dup().
    
    CID: #17217
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1d7993bd4076bf4b15807fcf340976123817bd0b
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Apr 14 21:54:17 2014 +0200

    tests: Fix use of tainted string in test_ioctl.
    
    CID: #17221
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 7f1039532d24908963a8f104b2c9c4d39998b701
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 25 13:57:38 2014 +0200

    cmake: Fix policy check.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit f79b7fa04ba9e6da442e81e46080de5be19f0eac
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Apr 16 15:44:10 2014 +0200

    cmake: Install cmake config in the correct directory.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 CMakeLists.txt       |    2 +-
 src/CMakeLists.txt   |    2 +-
 src/socket_wrapper.c |   16 ++++++++++++++--
 tests/echo_srv.c     |    8 ++++++++
 tests/test_ioctl.c   |    7 ++++++-
 5 files changed, 30 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9696f4d..6c50c2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,7 @@ install(
         ${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config-version.cmake
         ${CMAKE_CURRENT_BINARY_DIR}/socket_wrapper-config.cmake
     DESTINATION
-        ${CMAKE_INSTALL_DIR}
+        ${CMAKE_INSTALL_DIR}/socket_wrapper
     COMPONENT
         devel
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 50ac9ad..95a691f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -23,7 +23,7 @@ set_target_properties(
 )
 
 # This needs to be at the end
-if (CMAKE_VERSION VERSION_GREATER 2.8.13)
+if (POLICY CMP0026)
     cmake_policy(SET CMP0026 OLD)
 endif()
 get_target_property(SWRAP_LOCATION socket_wrapper LOCATION)
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 5ed9d9f..3b99814 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -608,6 +608,18 @@ static int libc_vopen(const char *pathname, int flags, va_list ap)
 	return fd;
 }
 
+static int libc_open(const char *pathname, int flags, ...)
+{
+	va_list ap;
+	int fd;
+
+	va_start(ap, flags);
+	fd = libc_vopen(pathname, flags, ap);
+	va_end(ap);
+
+	return fd;
+}
+
 static int libc_pipe(int pipefd[2])
 {
 	swrap_load_lib_function(SWRAP_LIBSOCKET, pipe);
@@ -1707,7 +1719,7 @@ static int swrap_get_pcap_fd(const char *fname)
 
 	if (fd != -1) return fd;
 
-	fd = open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644);
+	fd = libc_open(fname, O_WRONLY|O_CREAT|O_EXCL|O_APPEND, 0644);
 	if (fd != -1) {
 		struct swrap_file_hdr file_hdr;
 		file_hdr.magic		= 0xA1B2C3D4;
@@ -1725,7 +1737,7 @@ static int swrap_get_pcap_fd(const char *fname)
 		return fd;
 	}
 
-	fd = open(fname, O_WRONLY|O_APPEND, 0644);
+	fd = libc_open(fname, O_WRONLY|O_APPEND, 0644);
 
 	return fd;
 }
diff --git a/tests/echo_srv.c b/tests/echo_srv.c
index 9102a87..8f8f73f 100644
--- a/tests/echo_srv.c
+++ b/tests/echo_srv.c
@@ -262,6 +262,7 @@ static int socket_dup(int s)
     rc = getsockname(s2, (struct sockaddr *)&srv_ss2, &srv_ss2_len);
     if (rc == -1) {
         perror("getsockname");
+        close(s2);
         return -1;
     }
 
@@ -270,12 +271,14 @@ static int socket_dup(int s)
     rc = getpeername(s2, (struct sockaddr *)&cli_ss2, &cli_ss2_len);
     if (rc == -1) {
         perror("getpeername");
+        close(s2);
         return -1;
     }
 
     if (cli_ss1_len != cli_ss2_len ||
         srv_ss1_len != srv_ss2_len) {
         perror("length mismatch");
+        close(s2);
         return -1;
     }
 
@@ -318,6 +321,7 @@ static int socket_dup(int s)
     }
     default:
         perror("family mismatch");
+        close(s2);
         return -1;
     }
 
@@ -334,6 +338,7 @@ static int socket_dup(int s)
     rc = getsockname(s, (struct sockaddr *)&srv_ss3, &srv_ss3_len);
     if (rc == -1) {
         perror("getsockname");
+        close(s);
         return -1;
     }
 
@@ -342,12 +347,14 @@ static int socket_dup(int s)
     rc = getpeername(s, (struct sockaddr *)&cli_ss3, &cli_ss3_len);
     if (rc == -1) {
         perror("getpeername");
+        close(s);
         return -1;
     }
 
     if (cli_ss2_len != cli_ss3_len ||
         srv_ss2_len != srv_ss3_len) {
         perror("length mismatch");
+        close(s);
         return -1;
     }
 
@@ -390,6 +397,7 @@ static int socket_dup(int s)
     }
     default:
         perror("family mismatch");
+        close(s);
         return -1;
     }
 
diff --git a/tests/test_ioctl.c b/tests/test_ioctl.c
index 077e553..1f31c2e 100644
--- a/tests/test_ioctl.c
+++ b/tests/test_ioctl.c
@@ -33,6 +33,7 @@ static void teardown(void **state)
 {
 	char remove_cmd[256] = {0};
 	const char *swrap_dir = getenv("SOCKET_WRAPPER_DIR");
+	char *s;
 	int rc;
 
 	(void) state; /* unused */
@@ -40,7 +41,11 @@ static void teardown(void **state)
 	if (swrap_dir == NULL) {
 		return;
 	}
-	snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", swrap_dir);
+
+	/* Do not use a tainted string in snprintf */
+	s = strdup(swrap_dir);
+	snprintf(remove_cmd, sizeof(remove_cmd), "rm -rf %s", s);
+	free(s);
 
 	rc = system(remove_cmd);
 	if (rc < 0) {


-- 
Socket Wrapper Repository


More information about the samba-cvs mailing list