Merge pull request #150 from ajaybhargav/truncate-fix
Fix: length more than LFS_FILE_MAX should return error
This commit is contained in:
@@ -2864,6 +2864,10 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {
|
|||||||
return LFS_ERR_BADF;
|
return LFS_ERR_BADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size > LFS_FILE_MAX) {
|
||||||
|
return LFS_ERR_INVAL;
|
||||||
|
}
|
||||||
|
|
||||||
lfs_off_t oldsize = lfs_file_size(lfs, file);
|
lfs_off_t oldsize = lfs_file_size(lfs, file);
|
||||||
if (size < oldsize) {
|
if (size < oldsize) {
|
||||||
// need to flush since directly changing metadata
|
// need to flush since directly changing metadata
|
||||||
|
|||||||
Reference in New Issue
Block a user