mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-08-04 03:06:12 +00:00
fix(trail): check read() return for header bytes in readFrom/exportGpxFromFile
Mirrors the Waypoint::readFrom() hardening — reject a truncated trail snapshot instead of proceeding with garbage header fields. Consistency with the waypoint store's persistence path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fcdacaa3bc
commit
1521be3803
@@ -201,10 +201,10 @@ public:
|
|||||||
uint8_t ver = 0, res = 0;
|
uint8_t ver = 0, res = 0;
|
||||||
uint16_t cnt = 0;
|
uint16_t cnt = 0;
|
||||||
uint32_t accum = 0;
|
uint32_t accum = 0;
|
||||||
file.read(&ver, 1);
|
if (file.read(&ver, 1) != 1) return false;
|
||||||
file.read(&res, 1);
|
if (file.read(&res, 1) != 1) return false;
|
||||||
file.read((uint8_t*)&cnt, sizeof(cnt));
|
if (file.read((uint8_t*)&cnt, sizeof(cnt)) != (int)sizeof(cnt)) return false;
|
||||||
file.read((uint8_t*)&accum, sizeof(accum));
|
if (file.read((uint8_t*)&accum, sizeof(accum)) != (int)sizeof(accum)) return false;
|
||||||
if (ver != SAVE_VERSION || cnt > CAPACITY) return false;
|
if (ver != SAVE_VERSION || cnt > CAPACITY) return false;
|
||||||
if (_active) {
|
if (_active) {
|
||||||
_active = false;
|
_active = false;
|
||||||
@@ -344,10 +344,10 @@ public:
|
|||||||
uint8_t ver = 0, res = 0;
|
uint8_t ver = 0, res = 0;
|
||||||
uint16_t cnt = 0;
|
uint16_t cnt = 0;
|
||||||
uint32_t accum = 0;
|
uint32_t accum = 0;
|
||||||
file.read(&ver, 1);
|
if (file.read(&ver, 1) != 1) return 0;
|
||||||
file.read(&res, 1);
|
if (file.read(&res, 1) != 1) return 0;
|
||||||
file.read((uint8_t*)&cnt, sizeof(cnt));
|
if (file.read((uint8_t*)&cnt, sizeof(cnt)) != (int)sizeof(cnt)) return 0;
|
||||||
file.read((uint8_t*)&accum, sizeof(accum));
|
if (file.read((uint8_t*)&accum, sizeof(accum)) != (int)sizeof(accum)) return 0;
|
||||||
if (ver != SAVE_VERSION || cnt > CAPACITY) return 0;
|
if (ver != SAVE_VERSION || cnt > CAPACITY) return 0;
|
||||||
|
|
||||||
size_t total = gpxHeader(out);
|
size_t total = gpxHeader(out);
|
||||||
|
|||||||
Reference in New Issue
Block a user