summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-07-14 00:40:42 (GMT)
committerMinje Ahn <minje.ahn@samsung.com>2017-07-17 07:02:13 (GMT)
commit6339a446a14a52712bc3228a220ae6da9f2131e5 (patch)
tree92a8de66cb8d012563bf4024bb0203147d8a1f73 /server
parent25b3a21bb456c0ac4f0011e2a4c33374cf38a52f (diff)
downloadlibmedia-thumbnail-6339a446a14a52712bc3228a220ae6da9f2131e5.zip
libmedia-thumbnail-6339a446a14a52712bc3228a220ae6da9f2131e5.tar.gz
libmedia-thumbnail-6339a446a14a52712bc3228a220ae6da9f2131e5.tar.bz2
[SATIZENVUL-956] change strncpy to g_strlcpyrefs/changes/97/138797/4
Change-Id: Id4108ba3e01f4d06f7fa6c235d9213fb804b3e40 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'server')
-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;