mirror of
https://github.com/eledio-devices/thirdparty-littlefs.git
synced 2025-10-30 16:15:40 +01:00
Merge pull request #630 from Johnxjj/dev-johnxjj
add the limit, the cursor cannot be set to a negative number
This commit is contained in:
13
lfs.c
13
lfs.c
@@ -3076,9 +3076,18 @@ static lfs_soff_t lfs_file_rawseek(lfs_t *lfs, lfs_file_t *file,
|
||||
if (whence == LFS_SEEK_SET) {
|
||||
npos = off;
|
||||
} else if (whence == LFS_SEEK_CUR) {
|
||||
npos = file->pos + off;
|
||||
if ((lfs_soff_t)file->pos + off < 0) {
|
||||
return LFS_ERR_INVAL;
|
||||
} else {
|
||||
npos = file->pos + off;
|
||||
}
|
||||
} else if (whence == LFS_SEEK_END) {
|
||||
npos = lfs_file_rawsize(lfs, file) + off;
|
||||
lfs_soff_t res = lfs_file_rawsize(lfs, file) + off;
|
||||
if (res < 0) {
|
||||
return LFS_ERR_INVAL;
|
||||
} else {
|
||||
npos = res;
|
||||
}
|
||||
}
|
||||
|
||||
if (npos > lfs->file_max) {
|
||||
|
||||
Reference in New Issue
Block a user