mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Merge pull request #150 from ajaybhargav/truncate-fix
Fix: length more than LFS_FILE_MAX should return error
This commit is contained in:
		
							
								
								
									
										4
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -2864,6 +2864,10 @@ int lfs_file_truncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) { | ||||
|         return LFS_ERR_BADF; | ||||
|     } | ||||
|  | ||||
|     if (size > LFS_FILE_MAX) { | ||||
|         return LFS_ERR_INVAL; | ||||
|     } | ||||
|  | ||||
|     lfs_off_t oldsize = lfs_file_size(lfs, file); | ||||
|     if (size < oldsize) { | ||||
|         // need to flush since directly changing metadata | ||||
|   | ||||
		Reference in New Issue
	
	Block a user