mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Fix stack buffer overflow in mavlink_log_handler sscanf calls
- Increase LogEntry.filepath buffer from 60 to 256 bytes - Add width specifiers to sscanf calls (%255s and %1023s) to prevent buffer overflow - Prevents remote DoS vulnerability when parsing logdata.txt with excessively long filenames Co-authored-by: dakejahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
parent
f219c9f3b9
commit
338595edd1
@ -174,7 +174,7 @@ void MavlinkLogHandler::state_listing()
|
||||
char filepath[PX4_MAX_FILEPATH];
|
||||
|
||||
// If parsed lined successfully, send the entry
|
||||
if (sscanf(line, "%" PRIu32 " %" PRIu32 " %s", &time_utc, &size_bytes, filepath) != 3) {
|
||||
if (sscanf(line, "%" PRIu32 " %" PRIu32 " %1023s", &time_utc, &size_bytes, filepath) != 3) {
|
||||
PX4_DEBUG("sscanf failed");
|
||||
continue;
|
||||
}
|
||||
@ -506,7 +506,7 @@ bool MavlinkLogHandler::log_entry_from_id(uint16_t log_id, LogEntry *entry)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(line, "%" PRIu32 " %" PRIu32 " %s", &(entry->time_utc), &(entry->size_bytes), entry->filepath) != 3) {
|
||||
if (sscanf(line, "%" PRIu32 " %" PRIu32 " %255s", &(entry->time_utc), &(entry->size_bytes), entry->filepath) != 3) {
|
||||
PX4_DEBUG("sscanf failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ private:
|
||||
uint32_t time_utc{};
|
||||
uint32_t size_bytes{};
|
||||
FILE *fp{nullptr};
|
||||
char filepath[60];
|
||||
char filepath[256];
|
||||
uint32_t offset{};
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user