summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2017-07-13 11:24:15 +0900
committerMinje Ahn <minje.ahn@samsung.com>2017-07-13 13:36:19 +0900
commit25b3a21bb456c0ac4f0011e2a4c33374cf38a52f (patch)
treea717d478d8a44a421d3ca640108b1ff84226cda6
parent32fe300117df43130bd365049939122869933d20 (diff)
downloadlibmedia-thumbnail-submit/tizen/20170713.090438.tar.gz
libmedia-thumbnail-submit/tizen/20170713.090438.tar.bz2
libmedia-thumbnail-submit/tizen/20170713.090438.zip
Change-Id: I39ebc9662b05f6d2f5c6bb268500ec52bdd02438 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rw-r--r--packaging/libmedia-thumbnail.spec2
-rwxr-xr-xsrc/media-thumb-internal.c31
2 files changed, 24 insertions, 9 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index 84fd662..ab2e04c 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.10
+Version: 0.2.11
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index bf3be75..f9e0991 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -341,6 +341,25 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value
return MS_MEDIA_ERR_NONE;
}
+static int __media_thumb_safe_atoi(char *buffer, int *si)
+{
+ char *end = NULL;
+ errno = 0;
+ thumb_retvm_if(buffer == NULL || si == NULL, MS_MEDIA_ERR_INTERNAL, "invalid parameter");
+
+ const long sl = strtol(buffer, &end, 10);
+
+ thumb_retvm_if(end == buffer, MS_MEDIA_ERR_INTERNAL, "not a decimal number");
+ thumb_retvm_if('\0' != *end, MS_MEDIA_ERR_INTERNAL, "extra characters at end of input: %s", end);
+ thumb_retvm_if((LONG_MIN == sl || LONG_MAX == sl) && (ERANGE == errno), MS_MEDIA_ERR_INTERNAL, "out of range of type long");
+ thumb_retvm_if(sl > INT_MAX, MS_MEDIA_ERR_INTERNAL, "greater than INT_MAX");
+ thumb_retvm_if(sl < INT_MIN, MS_MEDIA_ERR_INTERNAL, "less than INT_MIN");
+
+ *si = (int)sl;
+
+ return MS_MEDIA_ERR_NONE;
+}
+
static int _media_thumb_get_data_from_exif(ExifData *ed,
void **thumb_data,
int *thumb_size,
@@ -401,8 +420,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed,
/* Get the contents of the tag in human-readable form */
char width[10] = {0,};
exif_entry_get_value(entry, width, 10);
-
- *thumb_width = atoi(width);
+ __media_thumb_safe_atoi(width, thumb_width);
} else {
thumb_warn("EXIF_TAG_IMAGE_WIDTH does not exist");
*thumb_width = 0;
@@ -414,8 +432,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed,
/* Get the contents of the tag in human-readable form */
char height[10] = {0, };
exif_entry_get_value(entry, height, 10);
-
- *thumb_height = atoi(height);
+ __media_thumb_safe_atoi(height, thumb_height);
} else {
thumb_warn("EXIF_TAG_IMAGE_LENGTH does not exist");
*thumb_height = 0;
@@ -431,8 +448,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed,
if (entry) {
char width[10] = {0,};
exif_entry_get_value(entry, width, 10);
-
- *origin_width = atoi(width);
+ __media_thumb_safe_atoi(width, origin_width);
} else {
thumb_warn("EXIF_TAG_PIXEL_X_DIMENSION does not exist");
*origin_width = 0;
@@ -444,8 +460,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed,
if (entry) {
char height[10] = {0, };
exif_entry_get_value(entry, height, 10);
-
- *origin_height = atoi(height);
+ __media_thumb_safe_atoi(height, origin_height);
} else {
thumb_warn("EXIF_TAG_PIXEL_Y_DIMENSION does not exist");
*origin_height = 0;