Skip to content

Commit

Permalink
mavlink_ftp: ensure there's enough space for the 2. path in _workRename
Browse files Browse the repository at this point in the history
Prevents accessing invalid memory when reading ptr + oldpath_sz + 1 and
oldpath_sz fills out the whole or N-1 bytes of the payload.
  • Loading branch information
bkueng committed Apr 5, 2024
1 parent c759caf commit f3bbe73
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/mavlink/mavlink_ftp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ MavlinkFTP::_workRename(PayloadHeader *payload)
char *ptr = _data_as_cstring(payload);
size_t oldpath_sz = strlen(ptr);

if (oldpath_sz == payload->size) {
if (oldpath_sz + 2 >= payload->size) {
// no newpath
errno = EINVAL;
return kErrFailErrno;
Expand Down

0 comments on commit f3bbe73

Please sign in to comment.