summaryrefslogtreecommitdiff
path: root/server/thumb-server-internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'server/thumb-server-internal.c')
-rwxr-xr-xserver/thumb-server-internal.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index ff9e627..5974be3 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -355,7 +355,6 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
unsigned char *data = NULL;
int thumb_w = 0;
int thumb_h = 0;
- int max_length = 0;
char *thumb_path = NULL;
int alpha = 0;
bool is_saved = FALSE;
@@ -363,9 +362,8 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_retvm_if(req_msg == NULL || res_msg == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
const char *origin_path = req_msg->org_path;
+ memset(res_msg->dst_path, 0, MAX_FILEPATH_LEN);
thumb_path = res_msg->dst_path;
- thumb_path[0] = '\0';
- max_length = sizeof(res_msg->dst_path) -1;
res_msg->status = MS_MEDIA_ERR_NONE;
if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
@@ -374,21 +372,19 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
return MS_MEDIA_ERR_FILE_NOT_EXIST;
}
- err = _media_thumb_get_thumb_from_db(origin_path, thumb_path, max_length, req_msg->uid);
+ err = _media_thumb_get_thumb_from_db(origin_path, thumb_path, MAX_FILEPATH_LEN, req_msg->uid);
if (err == MS_MEDIA_ERR_NONE) {
thumb_dbg_slog("Thumb path : %s", thumb_path);
return MS_MEDIA_ERR_NONE;
} else {
if (strlen(thumb_path) == 0) {
- err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, req_msg->uid);
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, MAX_FILEPATH_LEN, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_get_hash_name failed - %d", err);
- strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
+ SAFE_STRLCPY(thumb_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
res_msg->status = err;
return err;
}
-
- thumb_path[strlen(thumb_path)] = '\0';
}
}
@@ -403,7 +399,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_thumbnail_get_data failed - %d", err);
SAFE_FREE(data);
- strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
+ SAFE_STRLCPY(thumb_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
res_msg->status = err;
goto DB_UPDATE;
@@ -430,7 +426,7 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_err("save_to_file_with_evas failed - %d", err);
SAFE_FREE(data);
- strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
+ SAFE_STRLCPY(thumb_path, THUMB_EMPTY_STR, MAX_FILEPATH_LEN);
res_msg->status = err;
return err;
} else {
@@ -479,8 +475,16 @@ _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_retvm_if(req_msg == NULL || res_msg == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid msg");
const char *origin_path = req_msg->org_path;
- thumb_w = req_msg->thumb_width;
- thumb_h = req_msg->thumb_height;
+ if (req_msg->thumb_width > 0)
+ thumb_w = req_msg->thumb_width;
+ else
+ thumb_w = THUMB_DEFAULT_WIDTH;
+
+ if (req_msg->thumb_height > 0)
+ thumb_h = req_msg->thumb_height;
+ else
+ thumb_h = THUMB_DEFAULT_HEIGHT;
+
res_msg->status = MS_MEDIA_ERR_NONE;
res_msg->msg_type = THUMB_RESPONSE_RAW_DATA;