mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
LP-625 Fix for unsafe use of temporary data
This commit is contained in:
parent
42c14a2a0b
commit
ab1a825417
@ -229,15 +229,16 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||
// cycle until there is space for another object
|
||||
while (start + header_len + 1 < data_len) {
|
||||
memset(&fields, 0xFF, total_len);
|
||||
uint8_t *tmp = logEntry->getData().Data; // avoid compiler warning regarding addressing a temporary make sure tmp lives until after memcpy
|
||||
memcpy(&fields, &tmp[start], header_len);
|
||||
ExtendedDebugLogEntry::DataFields tmp = logEntry->getData();
|
||||
memcpy(&fields, &tmp.Data[start], header_len);
|
||||
|
||||
// check wether a packed object is found
|
||||
// note that empty data blocks are set as 0xFF in flight side to minimize flash wearing
|
||||
// thus as soon as this read outside of used area, the test will fail as lenght would be 0xFFFF
|
||||
quint32 toread = header_len + fields.Size;
|
||||
if (!(toread + start > data_len)) {
|
||||
uint8_t *tmp = logEntry->getData().Data; // avoid compiler warning regarding addressing a temporary make sure tmp lives until after memcpy
|
||||
memcpy(&fields, &tmp[start], toread);
|
||||
tmp = logEntry->getData();
|
||||
memcpy(&fields, &tmp.Data[start], toread);
|
||||
ExtendedDebugLogEntry *subEntry = new ExtendedDebugLogEntry();
|
||||
subEntry->setData(fields, m_objectManager);
|
||||
m_logEntries << subEntry;
|
||||
|
Loading…
x
Reference in New Issue
Block a user