summaryrefslogtreecommitdiff
path: root/src/media-thumb-internal.c
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-10-16 02:34:01 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2015-10-16 02:34:01 (GMT)
commitd09bbffceb2babe51000ff3042c09febc3afaa09 (patch)
tree60e8fa7bba0b6bfe710cd0d9a314d5848c2d9f8d /src/media-thumb-internal.c
parent43c07c05dd6821a249405477d8bd7912a11ff439 (diff)
downloadlibmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.zip
libmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.tar.gz
libmedia-thumbnail-d09bbffceb2babe51000ff3042c09febc3afaa09.tar.bz2
Change-Id: I0da7fbf08691fc8a262584d0e4f8edbfbd809b45 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src/media-thumb-internal.c')
-rwxr-xr-xsrc/media-thumb-internal.c21
1 files changed, 16 insertions, 5 deletions
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;