summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunkyu Im <munkyu.im@samsung.com>2017-03-21 18:33:23 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2017-04-03 14:13:43 +0900
commit17121164ce3f89a75081ee53257808dacf6efec7 (patch)
treedb08eec7b6edd9ac888864aefa667ed7be60463b
parentc56b3dcb3246308dcaa0cb7a87a9425522f63817 (diff)
downloadsdb-17121164ce3f89a75081ee53257808dacf6efec7.tar.gz
sdb-17121164ce3f89a75081ee53257808dacf6efec7.tar.bz2
sdb-17121164ce3f89a75081ee53257808dacf6efec7.zip
misc: fix wrong statements
- wrong assignment. - null pointer dereference. Change-Id: If109ea31bd734325961881e166dde18a2ead1640 Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
-rw-r--r--src/adb_auth_host.c5
-rwxr-xr-xsrc/sockets.c4
-rwxr-xr-xsrc/transport.c16
3 files changed, 16 insertions, 9 deletions
diff --git a/src/adb_auth_host.c b/src/adb_auth_host.c
index 3dc7a5c..c1f237a 100644
--- a/src/adb_auth_host.c
+++ b/src/adb_auth_host.c
@@ -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) {
diff --git a/src/sockets.c b/src/sockets.c
index 694b111..722091d 100755
--- a/src/sockets.c
+++ b/src/sockets.c
@@ -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;
}
diff --git a/src/transport.c b/src/transport.c
index 5e4349d..8fc8309 100755
--- a/src/transport.c
+++ b/src/transport.c
@@ -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);