sensord: fix the svace issue because of using non-terminated string 19/60919/1
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 3 Mar 2016 03:05:46 +0000 (12:05 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Thu, 3 Mar 2016 03:05:46 +0000 (12:05 +0900)
Change-Id: Ibcbee0bac176f72c647639f8fb950dca1cf8fe70
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/shared/command_common.h
src/shared/csocket.cpp

index a75415c..bb67f70 100644 (file)
@@ -23,8 +23,8 @@
 #include <cpacket.h>
 #include <sensor_common.h>
 
-#define COMMAND_CHANNEL_PATH           "/tmp/sensord_command_socket"
-#define EVENT_CHANNEL_PATH                     "/tmp/sensord_event_socket"
+#define COMMAND_CHANNEL_PATH           "/tmp/sensord_command_socket\0"
+#define EVENT_CHANNEL_PATH                     "/tmp/sensord_event_socket\0"
 
 #define MAX_HANDLE                     256
 #define MAX_HANDLE_REACHED     -2
index 513c4b1..c6e7998 100644 (file)
@@ -95,8 +95,7 @@ bool csocket::bind (const char *sock_path)
 
        m_addr.sun_family = AF_UNIX;
 
-       strncpy(m_addr.sun_path, sock_path, sizeof(m_addr.sun_path));
-       m_addr.sun_path[sizeof(m_addr.sun_path)-1] = '\0';
+       strncpy(m_addr.sun_path, sock_path, strlen(sock_path));
 
        length = strlen(m_addr.sun_path) + sizeof(m_addr.sun_family);
 
@@ -297,8 +296,7 @@ bool csocket::connect(const char *sock_path)
 
        m_addr.sun_family = AF_UNIX;
 
-       strncpy(m_addr.sun_path, sock_path, sizeof(m_addr.sun_path));
-       m_addr.sun_path[sizeof(m_addr.sun_path)-1] = '\0';
+       strncpy(m_addr.sun_path, sock_path, strlen(sock_path));
 
        addr_len = strlen(m_addr.sun_path) + sizeof(m_addr.sun_family);