mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	Fix: length more than LFS_FILE_MAX should return error
To make lfs_file_truncate inline with ftruncate function, when -ve or size more than maximum file size is passed to function it should return invalid parameter error. In LFS case LFS_ERR_INVAL. Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
This commit is contained in:
		
				
					committed by
					
						 Christopher Haster
						Christopher Haster
					
				
			
			
				
	
			
			
			
						parent
						
							0907ba7813
						
					
				
				
					commit
					905727b684
				
			
							
								
								
									
										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; |         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