misc: fix wrong statements
authorMunkyu Im <munkyu.im@samsung.com>
Tue, 21 Mar 2017 09:33:23 +0000 (18:33 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 3 Apr 2017 05:13:43 +0000 (14:13 +0900)
 - wrong assignment.
 - null pointer dereference.

Change-Id: If109ea31bd734325961881e166dde18a2ead1640
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
src/adb_auth_host.c
src/sockets.c
src/transport.c

index 3dc7a5c7e1c0e77966c07766b4c71f09c8701317..c1f237ae2d970f60692d1c7d001c2db8bf6c62f1 100644 (file)
@@ -31,6 +31,7 @@
 #include "sdb.h"
 #include "adb_auth.h"
 #include "utils.h"
+#include "strutils.h"
 
 /* HACK: we need the RSAPublicKey struct
  * but RSA_verify conflits with openssl */
@@ -139,7 +140,7 @@ static int write_public_keyfile(RSA *private_key, const char *private_key_path)
        FILE *outfile = NULL;
        char path[PATH_MAX], info[MAX_PAYLOAD_V1];
        uint8_t *encoded = NULL;
-       size_t encoded_length;
+       int encoded_length;
        int ret = 0;
 
        if (snprintf(path, sizeof(path), "%s.pub", private_key_path)
@@ -349,7 +350,7 @@ static void get_vendor_keys(struct listnode *list) {
        adb_keys_path = getenv("ADB_VENDOR_KEYS");
        if (!adb_keys_path)
                return;
-       strncpy(keys_path, adb_keys_path, sizeof(keys_path));
+       s_strncpy(keys_path, adb_keys_path, sizeof(keys_path));
 
        path = adb_strtok_r(keys_path, ENV_PATH_SEPARATOR_STR, &save);
        while (path) {
index 694b111c33e98db31861dc6069e25a5168e40d8e..722091d226e29f950d823cb6da6bfebee7c7a768 100755 (executable)
@@ -798,7 +798,9 @@ static int handle_request_with_t(SDB_SOCKET* socket, char* service, TRANSPORT* t
             }
         }
 sendfail:
-        sendfailmsg(socket->fd, forward_err);
+        if (forward_err) {
+            sendfailmsg(socket->fd, forward_err);
+        }
         return 0;
     }
 
index 5e4349d610779b5f5da1cfb0c39e5ecc29af0dc6..8fc83095f8d3a51dd3fc0540e492b21dcd43190a 100755 (executable)
@@ -1062,10 +1062,12 @@ void wakeup_select_func(int _fd, unsigned ev, void *data) {
                                t->encryption = ENCR_OFF; // 현재 연결에 대한 암호화 모드를 off
                                sendokmsg(sock->fd, "Encryption is OFF");
                   }
-                  else{
-                          send_encr_fail(sock, t, ENCR_OFF_FAIL);
-                               sendfailmsg(sock->fd, "Encryption OFF failed");
-                               LOG_ERROR("security_deinit failed");
+           else{
+               if(sock != NULL) {
+                   send_encr_fail(sock, t, ENCR_OFF_FAIL);
+                   sendfailmsg(sock->fd, "Encryption OFF failed");
+               }
+               LOG_ERROR("security_deinit failed");
                   }
                   local_socket_close(sock);
           }
@@ -1091,8 +1093,10 @@ void wakeup_select_func(int _fd, unsigned ev, void *data) {
           }
           else if(p->msg.arg0 == ENCR_OFF_FAIL){ // sdbd에서 암호화 모드 off에 실패했을 경우 받는 메시지
                   //t->encryption = ENCR_ON;
-                       sendfailmsg(sock->fd, "Encryption OFF failed");
-                  local_socket_close(sock);
+           if (sock != NULL) {
+               sendfailmsg(sock->fd, "Encryption OFF failed");
+               local_socket_close(sock);
+           }
           }
           put_apacket(enc_p);