fix N_SE-42418 image resolution check
authorKyusung Cho <ks0128.cho@samsung.com>
Tue, 25 Jun 2013 07:20:45 +0000 (16:20 +0900)
committerKyusung Cho <ks0128.cho@samsung.com>
Tue, 25 Jun 2013 07:20:45 +0000 (16:20 +0900)
Change-Id: I6b3258d7a637b27a94048176a9245e271a9ed394
Signed-off-by: Kyusung Cho <ks0128.cho@samsung.com>
src/FUixVision_ImageFeatureManagerImpl.cpp
src/FUixVision_ImageFeatureManagerImpl.h

index 5454ad4..ffd9b89 100644 (file)
@@ -28,6 +28,8 @@ namespace Tizen { namespace Uix { namespace Vision
 _ImageFeatureManagerImpl::_ImageFeatureManagerImpl(void)
     : __imageFeatureManager(0)
     , __readOnly(false)
+       , __minSupportedSize(100)
+       , __maxSupportedResolution(16000000)
 {
 }
 
@@ -66,8 +68,21 @@ _ImageFeatureManagerImpl::InitDB(void)
 int
 _ImageFeatureManagerImpl::AddFeature(const Tizen::Base::String& filepath)
 {
+    Tizen::Media::ImageFormat imgFormat;
+    int imgWidth = 0, imgHeight = 0;
+    result r = Tizen::Media::ImageBuffer::GetImageInfo(filepath, imgFormat, imgWidth, imgHeight);
+    if (IsFailed(r))
+    {
+       return -1;
+    }
+
+    if ((imgWidth < __minSupportedSize || imgHeight < __minSupportedSize) || (imgWidth*imgHeight > __maxSupportedResolution))
+    {
+       return -1;
+    }
+
     Tizen::Media::ImageBuffer imBuf;
-    result r = imBuf.Construct(filepath, null, false);
+    r = imBuf.Construct(filepath, null, false);
     if (IsFailed(r))
     {
         return -1;
@@ -92,6 +107,12 @@ _ImageFeatureManagerImpl::AddFeature(const unsigned char* data, int width, int h
     {
         return -1;
     }
+
+    if ((width < __minSupportedSize || height < __minSupportedSize) || (width*height > __maxSupportedResolution))
+    {
+       return -1;
+    }
+
     Tizen::Text::Utf8Encoding utf8;
     std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(info));
     int index = (int) __imageFeatureManager->addImageToDB(data, width, height, (char*) pBuffer->GetPointer());
index 42c905f..f2e9b65 100644 (file)
@@ -61,6 +61,8 @@ private:
     Tizen::Base::String                      __path;
     Tizen::Base::Collection::ArrayListT<int> __indices;
        bool                                                                     __readOnly;
+    int __minSupportedSize;
+    int __maxSupportedResolution;
 };
 
 } } } //Tizen::Uix::Vision