diff --git a/frameworks/native/rdb/include/sqlite_global_config.h b/frameworks/native/rdb/include/sqlite_global_config.h index 21edf315c..4138ea185 100644 --- a/frameworks/native/rdb/include/sqlite_global_config.h +++ b/frameworks/native/rdb/include/sqlite_global_config.h @@ -31,6 +31,7 @@ public: static constexpr int DB_WAL_SIZE_LIMIT = 200 * 1024 * 1024; /* default wal file maximum size : 200M */ static constexpr int WAL_AUTO_CHECKPOINT = 100; /* 100 pages */ static constexpr int APP_DEFAULT_UMASK = 0002; + static constexpr int SQLITE_MAX_COLUMN = 2000; static constexpr char ATTACH_BACKUP_SQL[] = "ATTACH ? AS backup KEY ?"; static constexpr char ATTACH_SQL[] = "ATTACH ? AS ? KEY ?"; static constexpr char EXPORT_SQL[] = "SELECT export_database('backup')"; diff --git a/frameworks/native/rdb/mock/include/sqlite_global_config.h b/frameworks/native/rdb/mock/include/sqlite_global_config.h index a8b1cf24e..08900d551 100644 --- a/frameworks/native/rdb/mock/include/sqlite_global_config.h +++ b/frameworks/native/rdb/mock/include/sqlite_global_config.h @@ -32,6 +32,7 @@ public: static constexpr int DB_WAL_SIZE_LIMIT = 200 * 1024 * 1024; /* default wal file maximum size : 200M */ static constexpr int WAL_AUTO_CHECKPOINT = 100; /* 100 pages */ static constexpr int APP_DEFAULT_UMASK = 0002; + static constexpr int SQLITE_MAX_COLUMN = 2000; static constexpr char ATTACH_BACKUP_SQL[] = "ATTACH ? AS backup KEY ?"; static constexpr char ATTACH_SQL[] = "ATTACH ? AS ? KEY ?"; static constexpr char EXPORT_SQL[] = "SELECT export_database('backup')"; diff --git a/frameworks/native/rdb/src/values_bucket.cpp b/frameworks/native/rdb/src/values_bucket.cpp index eee1d9626..053c66d09 100644 --- a/frameworks/native/rdb/src/values_bucket.cpp +++ b/frameworks/native/rdb/src/values_bucket.cpp @@ -14,6 +14,8 @@ */ #include "values_bucket.h" +#include "sqlite_global_config.h" +#include "logger.h" namespace OHOS { namespace NativeRdb { @@ -124,6 +126,10 @@ ValuesBucket *ValuesBucket::Unmarshalling(Parcel &parcel) int mapSize = parcel.ReadInt32(); std::map valuesMap; ValueObject *value = nullptr; + if (mapSize > GlobalExpr::SQLITE_MAX_COLUMN) { + LOG_ERROR("The mapSize is %{public}d ", mapSize); + return new ValuesBucket(valuesMap); + } for (int i = 0; i < mapSize; i++) { std::string key = parcel.ReadString(); value = parcel.ReadParcelable();