Fix for svace issues 39/175039/2
authorshikha.ta <shikha.ta@samsung.com>
Fri, 6 Apr 2018 06:22:45 +0000 (11:52 +0530)
committermanish.r <manish.r@samsung.com>
Mon, 9 Apr 2018 07:54:36 +0000 (13:24 +0530)
Change-Id: I9a97f784358be1d7c9f36aa58944b413c22f2e86
Signed-off-by: shikha.ta <shikha.ta@samsung.com>
src/sdb.c
src/services.c
src/subprocess.c

index 079d9fc..cbe42b3 100644 (file)
--- a/src/sdb.c
+++ b/src/sdb.c
@@ -472,7 +472,7 @@ int handle_encr_packet(apacket* p, atransport *t){
             D("security_init error\n");
             send_encr_fail(p, t, ENCR_ON_FAIL);
             t->encryption = ENCR_OFF;
-            if (retVal == -1)
+            if (retVal == 0)
             {
                 security_deinit(t->sessionID);
             }
index 06550fc..d82a0b3 100644 (file)
@@ -867,8 +867,7 @@ static int create_sync_subprocess(void (*func)(int, void *), void* cookie) {
         sdb_close(s[1]);
         // FIXME: do not wait child process hear
         //waitpid(pid, &ret, 0);
-    }
-    if (pid < 0) {
+    } else {
         D("- fork failed: errno:%d -\n", errno);
         sdb_close(s[0]);
         sdb_close(s[1]);
index 9241d85..0bf6c1b 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "sysdeps.h"
 #include "sdb.h"
-
 #define SHELL_COMMAND "/bin/sh"
 
 /* to send ptm fd to sdbd main */
@@ -150,7 +149,7 @@ int main (int argc, char **argv, char **envp)
             return -1;
         }
 
-        char *sockpath = strdup(tmptext);
+        char *sockpath = strndup(tmptext, strlen(tmptext));
         if (sockpath == NULL) {
             fprintf(stderr, "sdbu socket path error, %d\n", errno);
             sdb_close(sock);
@@ -158,7 +157,7 @@ int main (int argc, char **argv, char **envp)
         }
         memset(&addr, 0, sizeof(addr));
         addr.sun_family = AF_LOCAL;
-        strncpy(addr.sun_path, sockpath, strlen(sockpath));
+        strncpy(addr.sun_path, sockpath, strlen(sockpath)+1);
         int slen = offsetof(struct sockaddr_un, sun_path) + strlen(sockpath);
         if (bind(sock, (struct sockaddr *)&addr, slen) == -1) {
             fprintf(stderr, "sdbu socket bind error, %d\n", errno);