diff options
author | Andrew Duggan <aduggan@synaptics.com> | 2015-03-16 11:37:52 -0700 |
---|---|---|
committer | Andrew Duggan <aduggan@synaptics.com> | 2015-03-16 11:37:52 -0700 |
commit | 1bf175e042630bdb13de83622ce67ca3f3cd522d (patch) | |
tree | b916211ab23929842d49f75775fe2cfd476fb5ef | |
parent | dc8385559de574637738ab6d120e12e27e569a55 (diff) | |
download | rmi4utils-1bf175e042630bdb13de83622ce67ca3f3cd522d.tar.gz |
Change m_imageSize to signed since it's value is set by the result of tellg and
tellg returns -1 when there is an error. Also, check the result of tellg.
-rw-r--r-- | rmi4update/firmware_image.cpp | 5 | ||||
-rw-r--r-- | rmi4update/firmware_image.h | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/rmi4update/firmware_image.cpp b/rmi4update/firmware_image.cpp index fc1da97..8acc2d6 100644 --- a/rmi4update/firmware_image.cpp +++ b/rmi4update/firmware_image.cpp @@ -53,7 +53,10 @@ int FirmwareImage::Initialize(const char * filename) return UPDATE_FAIL_OPEN_FIRMWARE_IMAGE; ifsFile.seekg(0, ios::end); - m_imageSize = (unsigned long)ifsFile.tellg(); + m_imageSize = ifsFile.tellg(); + if (m_imageSize < 0) + return UPDATE_FAIL_OPEN_FIRMWARE_IMAGE; + m_memBlock = new unsigned char[m_imageSize]; ifsFile.seekg(0, ios::beg); ifsFile.read((char*)m_memBlock, m_imageSize); diff --git a/rmi4update/firmware_image.h b/rmi4update/firmware_image.h index 4dec1d8..1c91324 100644 --- a/rmi4update/firmware_image.h +++ b/rmi4update/firmware_image.h @@ -71,7 +71,7 @@ private: unsigned long m_firmwareSize; unsigned long m_configSize; unsigned long m_lockdownSize; - unsigned long m_imageSize; + long m_imageSize; unsigned long m_firmwareBuildID; unsigned short m_packageID; unsigned char m_bootloaderVersion; |