diff options
author | Haejeong Kim <backto.kim@samsung.com> | 2017-04-25 14:15:35 +0900 |
---|---|---|
committer | Haejeong Kim <backto.kim@samsung.com> | 2017-04-25 14:15:35 +0900 |
commit | 07bf2f5ed03a79aeab5a094788fe3a8564810bc1 (patch) | |
tree | 8e9f5b85b541f2e0a1766370a4eb8351ab1b6f93 | |
parent | f2915aa1f407cfb76beb0ba1975d802dd65ade0f (diff) | |
download | media-controller-07bf2f5ed03a79aeab5a094788fe3a8564810bc1.tar.gz media-controller-07bf2f5ed03a79aeab5a094788fe3a8564810bc1.tar.bz2 media-controller-07bf2f5ed03a79aeab5a094788fe3a8564810bc1.zip |
change strncpy to g_strlcpysubmit/tizen/20170425.065515accepted/tizen/unified/20170426.061707
Change-Id: Ie53b67f8d98a3b94674cffdfcddf18dbd0e47ebb
-rwxr-xr-x | include/media_controller_private.h | 2 | ||||
-rwxr-xr-x | packaging/capi-media-controller.spec | 2 | ||||
-rwxr-xr-x | src/media_controller_ipc.c | 6 | ||||
-rwxr-xr-x | svc/media_controller_db_util.c | 2 | ||||
-rwxr-xr-x | svc/media_controller_socket.c | 2 |
5 files changed, 8 insertions, 6 deletions
diff --git a/include/media_controller_private.h b/include/media_controller_private.h index a6e97f8..d28007d 100755 --- a/include/media_controller_private.h +++ b/include/media_controller_private.h @@ -89,6 +89,8 @@ extern "C" { #define MC_SAFE_FREE(src) { if (src) {free(src); src = NULL; } } #define MC_SAFE_G_FREE(src) { if (src) {g_free(src); src = NULL; } } +#define MC_SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n); + #define MC_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE) #define MC_STRING_DELIMITER "VAL_SEP" diff --git a/packaging/capi-media-controller.spec b/packaging/capi-media-controller.spec index 20159cd..c549e4e 100755 --- a/packaging/capi-media-controller.spec +++ b/packaging/capi-media-controller.spec @@ -1,6 +1,6 @@ Name: capi-media-controller Summary: A media controller library in Tizen Native API -Version: 0.1.36 +Version: 0.1.37 Release: 1 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_controller_ipc.c b/src/media_controller_ipc.c index 356098e..b8f0fc6 100755 --- a/src/media_controller_ipc.c +++ b/src/media_controller_ipc.c @@ -317,7 +317,7 @@ int mc_ipc_send_message_to_server(mc_msg_type_e msg_type, const int type, const send_msg.pid = getpid(); send_msg.uid = getuid(); send_msg.msg_size = request_msg_size; - strncpy(send_msg.msg, request_msg, sizeof(send_msg.msg) - 1); + MC_SAFE_STRLCPY(send_msg.msg, request_msg, sizeof(send_msg.msg)); /*Create Socket*/ ret = mc_ipc_create_client_socket(MC_TIMEOUT_SEC_5, &sock_info); @@ -327,7 +327,7 @@ int mc_ipc_send_message_to_server(mc_msg_type_e msg_type, const int type, const /*Set server Address*/ memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sun_family = AF_UNIX; - strncpy(serv_addr.sun_path, MC_IPC_PATH, sizeof(serv_addr.sun_path) - 1); + MC_SAFE_STRLCPY(serv_addr.sun_path, MC_IPC_PATH, sizeof(serv_addr.sun_path)); /* Connecting to the media db server */ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { @@ -410,7 +410,7 @@ int mc_ipc_service_connect(const int type) /*Set server Address*/ memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sun_family = AF_UNIX; - strncpy(serv_addr.sun_path, MC_SOCK_ACTIVATION_PATH, sizeof(serv_addr.sun_path) - 1); + MC_SAFE_STRLCPY(serv_addr.sun_path, MC_SOCK_ACTIVATION_PATH, sizeof(serv_addr.sun_path)); /* Connecting to the media controller service */ if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { diff --git a/svc/media_controller_db_util.c b/svc/media_controller_db_util.c index c158582..a621ea4 100755 --- a/svc/media_controller_db_util.c +++ b/svc/media_controller_db_util.c @@ -132,7 +132,7 @@ static char* __mc_get_db_name(uid_t uid) memset(result_psswd, 0, sizeof(result_psswd)); if (uid == getuid()) { - strncpy(result_psswd, MC_DB_NAME, sizeof(result_psswd)); + MC_SAFE_STRLCPY(result_psswd, MC_DB_NAME, sizeof(result_psswd)); grpinfo = getgrnam("users"); if (grpinfo == NULL) { mc_error("getgrnam(users) returns NULL !"); diff --git a/svc/media_controller_socket.c b/svc/media_controller_socket.c index a2bfde9..6e76b54 100755 --- a/svc/media_controller_socket.c +++ b/svc/media_controller_socket.c @@ -86,7 +86,7 @@ int mc_ipc_create_server_socket(mc_msg_port_type_e port, int *sock_fd) serv_addr.sun_family = AF_UNIX; unlink(MC_IPC_PATH); - strncpy(serv_addr.sun_path, MC_IPC_PATH, sizeof(serv_addr.sun_path) - 1); + MC_SAFE_STRLCPY(serv_addr.sun_path, MC_IPC_PATH, sizeof(serv_addr.sun_path)); /* Bind to the local address */ for (i = 0; i < 20; i++) { |