In 32-bit machine, the long size is 4 bytes. When calling the
ReadInt64() with timespec.tv_nsec. the buffer overflow is occurred.
Change-Id: Id5bcb26891c63b893b20d50e7dab4c38dbaea14b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
#include <atomic>
#include <climits>
+#include <limits>
#include "parcel-header-internal.hh"
void ParcelHeader::ReadFromParcel(tizen_base::Parcel* parcel) {
parcel->ReadInt32(&seq_num_);
- parcel->ReadInt64(reinterpret_cast<int64_t*>(&time_stamp_.tv_sec));
- parcel->ReadInt64(reinterpret_cast<int64_t*>(&time_stamp_.tv_nsec));
+
+ int64_t tv_sec = 0;
+ parcel->ReadInt64(&tv_sec);
+ time_stamp_.tv_sec = tv_sec & std::numeric_limits<time_t>::max();
+
+ int64_t tv_nsec = 0;
+ parcel->ReadInt64(&tv_nsec);
+ time_stamp_.tv_nsec = tv_nsec & std::numeric_limits<long>::max();
}
void ParcelHeader::SetSeqNum(int seq_num) {