summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-10-16 11:34:01 +0900
committerMinje Ahn <minje.ahn@samsung.com>2015-10-16 11:34:01 +0900
commitd09bbffceb2babe51000ff3042c09febc3afaa09 (patch)
tree60e8fa7bba0b6bfe710cd0d9a314d5848c2d9f8d
parent43c07c05dd6821a249405477d8bd7912a11ff439 (diff)
downloadlibmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.tar.gz
libmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.tar.bz2
libmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.zip
Change-Id: I0da7fbf08691fc8a262584d0e4f8edbfbd809b45 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/include/thumb-server-internal.h2
-rwxr-xr-xserver/thumb-server-internal.c9
-rwxr-xr-xsrc/media-thumb-internal.c21
-rwxr-xr-xsrc/util/media-thumb-util.c2
5 files changed, 24 insertions, 12 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index e6a25a9..25792dd 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.1.86
+Version: 0.1.87
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h
index 7869fe3..e3caa99 100755
--- a/server/include/thumb-server-internal.h
+++ b/server/include/thumb-server-internal.h
@@ -27,8 +27,6 @@
#ifndef _THUMB_DAEMON_INTERNAL_H_
#define _THUMB_DAEMON_INTERNAL_H_
-#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
-
typedef enum {
MEDIA_SERVER_PID = 1,
OTHERS_PID = 0,
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index eaf1745..dd282a0 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -46,6 +46,7 @@
#define THUMB_DEFAULT_HEIGHT 240
#define THUMB_BLOCK_SIZE 512
#define THUMB_ROOT_UID "0"
+#define THUMB_COMM_SOCK_PATH "/var/run/media-server/media_ipc_thumbcomm.socket"
static __thread char **arr_path;
static __thread uid_t *arr_uid;
@@ -486,7 +487,7 @@ static gboolean __thumb_server_send_msg_to_agent(int msg_type)
sock = sock_info.sock_fd;
serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcomm.socket");
+ strncpy(serv_addr.sun_path, THUMB_COMM_SOCK_PATH, strlen(THUMB_COMM_SOCK_PATH));
/* Connecting to the thumbnail server */
@@ -546,6 +547,7 @@ gboolean _thumb_server_prepare_socket(int *sock_fd)
if (ms_cynara_enable_credentials_passing(sock) != MS_MEDIA_ERR_NONE) {
thumb_err("ms_cynara_enable_credentials_passing failed");
+ close(sock);
return FALSE;
}
@@ -559,7 +561,8 @@ static char* _media_thumb_get_default_path(uid_t uid)
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_DEFAULT_PATH);
+ if (THUMB_DEFAULT_PATH != NULL)
+ result_psswd = strndup(THUMB_DEFAULT_PATH, strlen(THUMB_DEFAULT_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
@@ -757,7 +760,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
thumb_h = req_msg->thumb_height;
thumb_path = res_msg->dst_path;
thumb_path[0] = '\0';
- max_length = sizeof(res_msg->dst_path);
+ max_length = sizeof(res_msg->dst_path) -1;
if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
thumb_err("origin_path does not exist in file system.");
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index af8f593..8ea9637 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -1287,7 +1287,8 @@ static char* _media_thumb_mmc_get_path(uid_t uid)
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_MMC_PATH);
+ if (THUMB_MMC_PATH != NULL)
+ result_psswd = strndup(THUMB_MMC_PATH, strlen(THUMB_MMC_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
@@ -1322,7 +1323,8 @@ static char* _media_thumb_phone_get_path(uid_t uid)
char *result_psswd = NULL;
struct group *grpinfo = NULL;
if (uid == getuid()) {
- result_psswd = strdup(THUMB_PHONE_PATH);
+ if (THUMB_PHONE_PATH != NULL)
+ result_psswd = strndup(THUMB_PHONE_PATH, strlen(THUMB_PHONE_PATH));
grpinfo = getgrnam("users");
if (grpinfo == NULL) {
thumb_err("getgrnam(users) returns NULL !");
@@ -1358,6 +1360,7 @@ int _media_thumb_get_hash_name(const char *file_full_path,
char *hash_name = NULL;
/*char *thumb_dir = NULL;*/
char file_ext[255] = { 0 };
+ char *get_path = NULL;
int ret_len = 0;
media_thumb_store_type store_type = -1;
@@ -1384,13 +1387,21 @@ int _media_thumb_get_hash_name(const char *file_full_path,
}
if (store_type == THUMB_PHONE) {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_phone_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_phone_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
} else if (store_type == THUMB_MMC) {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_mmc_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_mmc_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
} else {
- ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", _media_thumb_phone_get_path(uid), file_ext, hash_name);
+ get_path = _media_thumb_phone_get_path(uid);
+ if (get_path != NULL)
+ ret_len = snprintf(thumb_hash_path, max_thumb_path - 1, "%s/.%s-%s.jpg", get_path, file_ext, hash_name);
}
+ SAFE_FREE(get_path);
+
if ((ret_len < 0) || (ret_len > (int)max_thumb_path)) {
thumb_err("invalid hash path ret_len[%d]", ret_len);
return MS_MEDIA_ERR_INTERNAL;
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index c487b6e..9d16281 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -90,7 +90,7 @@ _media_thumb_get_file_type(const char *file_full_path)
int _media_thumb_get_store_type_by_path(const char *full_path)
{
- if (full_path != NULL) {
+ if (full_path != NULL && THUMB_PATH_PHONE != NULL && THUMB_PATH_MMC != NULL) {
if (strncmp(full_path, THUMB_PATH_PHONE, strlen(THUMB_PATH_PHONE)) == 0) {
return THUMB_PHONE;
} else if (strncmp(full_path, THUMB_PATH_MMC, strlen(THUMB_PATH_MMC)) == 0) {