Change-Id: Ie2e63ff30e7cadf4867cc4c10e1c9e187d408566
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
namespace ldp_serialized {
+// Set max size of serialized file to prevent mmap with unexpected memory size.
+// 1MB. Adjustable
+#define MAX_SFILE_SIZE (1024 * 1024)
+
template <typename T>
struct type_helper;
return err("stat");
length = buf.st_size;
+ if (length > MAX_SFILE_SIZE) {
+ tslog::log("Serialized file size(", length, ") is too large. (>", MAX_SFILE_SIZE, ") bytes.\n");
+ return false;
+ }
mem = reinterpret_cast<uint8_t*>(mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, 0));
if (MAP_FAILED == mem)