Skip to content

Commit

Permalink
AP_Filesystem: correct comparison of signed/unsigned
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed May 4, 2020
1 parent ebc781b commit f43e48a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ int32_t AP_Filesystem_ROMFS::lseek(int fd, int32_t offset, int seek_from)
}
switch (seek_from) {
case SEEK_SET:
file[fd].ofs = MIN(file[fd].size, offset);
if (offset < 0) {
errno = EINVAL;
return -1;
}
file[fd].ofs = MIN(file[fd].size, (uint32_t)offset);
break;
case SEEK_CUR:
file[fd].ofs = MIN(file[fd].size, offset+file[fd].ofs);
Expand Down

0 comments on commit f43e48a

Please sign in to comment.