[Datacontrol] Fix SVACE issue 37/157637/2
authorPawel Kaczmarczyk <p.kaczmarczy@partner.samsung.com>
Wed, 25 Oct 2017 09:32:21 +0000 (11:32 +0200)
committerPawel Kaczmarczyk <p.kaczmarczy@partner.samsung.com>
Wed, 25 Oct 2017 12:16:35 +0000 (14:16 +0200)
[Verification] Passrate didn't change

Change-Id: I3c30d9d913bd0048c127b4e2435998a936542e4a
Signed-off-by: Pawel Kaczmarczyk <p.kaczmarczy@partner.samsung.com>
src/datacontrol/datacontrol_instance.cc

index da5e7ce..f59b282 100644 (file)
@@ -23,6 +23,7 @@
 #include <map>
 #include <string>
 #include <vector>
+#include <limits>
 
 #include "common/logger.h"
 #include "common/picojson.h"
@@ -138,8 +139,9 @@ static bool SQLColumnValue(result_set_cursor cursor, int columnIndex, picojson::
     }
     case DATA_CONTROL_SQL_COLUMN_TYPE_TEXT: {
       int size = data_control_sql_get_column_item_size(cursor, columnIndex);
-      if (DATA_CONTROL_ERROR_NONE > size) {
-        LoggerE("Getting column item size is failed with error : %s", ::get_error_message(size));
+      if (DATA_CONTROL_ERROR_NONE > size || INT_MAX == size) {
+        LoggerE("Getting column item size is failed with error : %s",
+                (INT_MAX == size) ? "integer overflow" : ::get_error_message(size));
         return false;
       }
       char* buffer = new char[size + 1];
@@ -155,8 +157,9 @@ static bool SQLColumnValue(result_set_cursor cursor, int columnIndex, picojson::
     }
     case DATA_CONTROL_SQL_COLUMN_TYPE_BLOB: {
       int size = data_control_sql_get_column_item_size(cursor, columnIndex);
-      if (DATA_CONTROL_ERROR_NONE > size) {
-        LoggerE("Getting column item size is failed with error : %s", ::get_error_message(size));
+      if (DATA_CONTROL_ERROR_NONE > size || INT_MAX == size) {
+        LoggerE("Getting column item size is failed with error : %s",
+                (INT_MAX == size) ? "integer overflow" : ::get_error_message(size));
         return false;
       }
       char* buffer = new char[size + 1];