summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaejeong Kim <backto.kim@samsung.com>2017-04-13 09:35:15 (GMT)
committerHaejeong Kim <backto.kim@samsung.com>2017-04-13 09:35:15 (GMT)
commit3a8c9ceded482a3df2056bfb98cef172deff16d3 (patch)
treeb279b0826744852c08c471bd0d435c02bbaf2481
parentf238209b9c81de1606cc43ea4c4e31465a73aaa3 (diff)
downloadlibmedia-thumbnail-3a8c9ceded482a3df2056bfb98cef172deff16d3.zip
libmedia-thumbnail-3a8c9ceded482a3df2056bfb98cef172deff16d3.tar.gz
libmedia-thumbnail-3a8c9ceded482a3df2056bfb98cef172deff16d3.tar.bz2
Change-Id: I1ad4f3628e6c96a78e2523ab8646adbd8ea48e9c
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/thumb-server-internal.c8
-rwxr-xr-xsrc/include/util/media-thumb-util.h1
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c20
4 files changed, 16 insertions, 15 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 9879137..1b911b4 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,6 +1,6 @@
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications
-Version: 0.2.1
+Version: 0.2.2
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index 8e0cff7..b9af459 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -226,7 +226,7 @@ static int __thumb_daemon_all_extract(uid_t uid)
break;
}
- strncpy(path, (const char *)sqlite3_column_text(sqlite_stmt, 0), sizeof(path));
+ SAFE_STRLCPY(path, (const char *)sqlite3_column_text(sqlite_stmt, 0), sizeof(path));
path[sizeof(path) - 1] = '\0';
thumb_dbg_slog("Path : %s", path);
@@ -266,7 +266,7 @@ int _thumb_daemon_process_queue_jobs(gpointer data)
recv_msg.msg_type = THUMB_REQUEST_DB_INSERT;
recv_msg.uid = uid;
- strncpy(recv_msg.org_path, path, sizeof(recv_msg.org_path));
+ SAFE_STRLCPY(recv_msg.org_path, path, sizeof(recv_msg.org_path));
recv_msg.org_path[sizeof(recv_msg.org_path) - 1] = '\0';
err = _thumb_daemon_process_job(&recv_msg, &res_msg);
@@ -355,7 +355,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
if (res_msg.msg_type == 0)
res_msg.msg_type = recv_msg.msg_type;
res_msg.request_id = recv_msg.request_id;
- strncpy(res_msg.org_path, recv_msg.org_path, recv_msg.origin_path_size);
+ SAFE_STRLCPY(res_msg.org_path, recv_msg.org_path, sizeof(res_msg.org_path));
res_msg.origin_path_size = recv_msg.origin_path_size;
if (res_msg.msg_type != THUMB_RESPONSE_RAW_DATA) {
res_msg.dest_path_size = strlen(res_msg.dst_path)+1;
@@ -417,7 +417,7 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type)
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, strlen(THUMB_COMM_SOCK_PATH));
+ SAFE_STRLCPY(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, sizeof(serv_addr.sun_path));
/* Connecting to the thumbnail server */
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index f8ff57a..046110c 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -28,6 +28,7 @@
#define SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
#define THUMB_MALLOC(src, size) { if (size <= 0) {src = NULL; } \
else { src = malloc(size); if (src) memset(src, 0x0, size); } }
+#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
typedef enum {
MEDIA_THUMB_BGRA, /* BGRA, especially provided for evas users */
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 693a3fa..3238092 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -438,8 +438,8 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
remain_size -= block_size;
}
- strncpy(msg->org_path, (char *)buf, msg->origin_path_size);
- strncpy(msg->dst_path, (char *)buf + msg->origin_path_size, msg->dest_path_size);
+ SAFE_STRLCPY(msg->org_path, (char *)buf, sizeof(msg->org_path));
+ SAFE_STRLCPY(msg->dst_path, (char *)buf + msg->origin_path_size, sizeof(msg->dst_path));
SAFE_FREE(msg->thumb_data);
if (msg->thumb_size > 0) {
@@ -487,7 +487,7 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size);
+ SAFE_STRLCPY(msg->org_path, (char*)buf + header_size, sizeof(msg->org_path));
if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) {
SAFE_FREE(buf);
@@ -495,7 +495,7 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size);
+ SAFE_STRLCPY(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, sizeof(msg->dst_path));
SAFE_FREE(buf);
*from_size = from_addr_size;
@@ -560,7 +560,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
+ SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
@@ -582,7 +582,7 @@ _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, in
/* Set requset message */
req_msg.msg_type = msg_type;
req_msg.uid = uid;
- strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
+ SAFE_STRLCPY(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
@@ -771,7 +771,7 @@ int _media_thumb_send_request()
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
+ SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
@@ -816,7 +816,7 @@ int _media_thumb_send_request()
req_msg.msg_type = req_manager->msg_type;
req_msg.request_id = 0;
req_msg.uid = req_manager->uid;
- strncpy(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
+ SAFE_STRLCPY(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
req_msg.dst_path[0] = '\0';
req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
@@ -891,7 +891,7 @@ int _media_thumb_raw_data_send_request()
memset(&serv_addr, 0, sizeof(serv_addr));
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strncpy(serv_addr.sun_path, THUMB_IPC_PATH, strlen(THUMB_IPC_PATH));
+ SAFE_STRLCPY(serv_addr.sun_path, THUMB_IPC_PATH, sizeof(serv_addr.sun_path));
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
@@ -937,7 +937,7 @@ int _media_thumb_raw_data_send_request()
req_msg.thumb_height = req_manager->height;
req_msg.uid = req_manager->uid;
- strncpy(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
+ SAFE_STRLCPY(req_msg.org_path, req_manager->path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
req_msg.dst_path[0] = '\0';