summaryrefslogtreecommitdiff
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
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>
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xserver/thumb-server-internal.c28
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c6
-rwxr-xr-xsrc/media-thumb-internal.c14
-rwxr-xr-xsrc/util/media-thumb-db.c2
5 files changed, 22 insertions, 30 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index ab2e04c..6a88d67 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.11
+Version: 0.2.12
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 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;
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 6b63959..5faed91 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -534,8 +534,6 @@ int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path
req_msg.msg_type = msg_type;
req_msg.uid = uid;
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;
req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
req_msg.thumb_size = 0;
@@ -586,7 +584,7 @@ int _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path
return recv_msg.status;
}
- strncpy(thumb_path, recv_msg.dst_path, max_length);
+ SAFE_STRLCPY(thumb_path, recv_msg.dst_path, max_length);
return MS_MEDIA_ERR_NONE;
}
@@ -755,7 +753,6 @@ int _media_thumb_send_request()
req_msg.request_id = 0;
req_msg.uid = req_manager->uid;
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;
req_msg.dest_path_size = 1;
@@ -873,7 +870,6 @@ int _media_thumb_raw_data_send_request()
req_msg.uid = req_manager->uid;
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;
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index f9e0991..65332c6 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -300,7 +300,7 @@ int _media_thumb_get_proper_thumb_size(int orig_w, int orig_h, int *thumb_w, int
return MS_MEDIA_ERR_NONE;
}
-int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value, int ifdtype, long tagtype)
+int _media_thumb_get_exif_info(ExifData *ed, int *value, int ifdtype, long tagtype)
{
ExifEntry *entry;
ExifIfd ifd;
@@ -327,14 +327,6 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
ExifByteOrder mByteOrder = exif_data_get_byte_order(ed);
short exif_value = exif_get_short(entry->data, mByteOrder);
*value = (int)exif_value;
- } else {
- /* Get the contents of the tag in human-readable form */
- if (buf == NULL) {
- thumb_err("buf is NULL");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
- exif_entry_get_value(entry, buf, max_size);
- buf[strlen(buf)] = '\0';
}
}
@@ -866,7 +858,7 @@ int _media_thumb_jpeg(const char *origin_path, const char *thumb_path, int thumb
if (ed) {
/* First, Get orientation from exif */
- err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
+ err = _media_thumb_get_exif_info(ed, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
if (err != MS_MEDIA_ERR_NONE) {
thumb_warn("_media_thumb_get_exif_info failed");
}
@@ -905,7 +897,7 @@ int _media_thumb_jpeg(const char *origin_path, const char *thumb_path, int thumb
} else {
ed = exif_data_new_from_file(origin_path);
if (ed) {
- err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
+ err = _media_thumb_get_exif_info(ed, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
if (err != MS_MEDIA_ERR_NONE) {
thumb_warn("_media_thumb_get_exif_info failed");
}
diff --git a/src/util/media-thumb-db.c b/src/util/media-thumb-db.c
index d955a46..5fdc614 100755
--- a/src/util/media-thumb-db.c
+++ b/src/util/media-thumb-db.c
@@ -58,7 +58,7 @@ int _media_thumb_get_thumb_from_db(const char *origin_path, char *thumb_path, in
}
if (sqlite3_step(stmt) == SQLITE_ROW) {
- strncpy(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length);
+ SAFE_STRLCPY(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length);
} else {
thumb_err("end of row [%s]", sqlite3_errmsg(db_handle));
SQLITE3_FINALIZE(stmt);