mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Kernel: Harden Ext2FileSystem Vector usage against OOM.
This commit is contained in:
		
							parent
							
								
									2ee1731966
								
							
						
					
					
						commit
						f05086a5d2
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		|  | @ -904,7 +904,8 @@ KResult Ext2FSInode::resize(u64 new_size) | ||||||
|         auto blocks_or_error = fs().allocate_blocks(fs().group_index_from_inode(index()), blocks_needed_after - blocks_needed_before); |         auto blocks_or_error = fs().allocate_blocks(fs().group_index_from_inode(index()), blocks_needed_after - blocks_needed_before); | ||||||
|         if (blocks_or_error.is_error()) |         if (blocks_or_error.is_error()) | ||||||
|             return blocks_or_error.error(); |             return blocks_or_error.error(); | ||||||
|         m_block_list.append(blocks_or_error.release_value()); |         if (!m_block_list.try_append(blocks_or_error.release_value())) | ||||||
|  |             return ENOMEM; | ||||||
|     } else if (blocks_needed_after < blocks_needed_before) { |     } else if (blocks_needed_after < blocks_needed_before) { | ||||||
|         if constexpr (EXT2_VERY_DEBUG) { |         if constexpr (EXT2_VERY_DEBUG) { | ||||||
|             dbgln("Ext2FSInode[{}]::resize(): Shrinking inode, old block list is {} entries:", identifier(), m_block_list.size()); |             dbgln("Ext2FSInode[{}]::resize(): Shrinking inode, old block list is {} entries:", identifier(), m_block_list.size()); | ||||||
|  | @ -1451,7 +1452,8 @@ KResultOr<Ext2FS::CachedBitmap*> Ext2FS::get_bitmap_block(BlockIndex bitmap_bloc | ||||||
|         dbgln("Ext2FS: Failed to load bitmap block {}", bitmap_block_index); |         dbgln("Ext2FS: Failed to load bitmap block {}", bitmap_block_index); | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
|     m_cached_bitmaps.append(make<CachedBitmap>(bitmap_block_index, move(block))); |     if (!m_cached_bitmaps.try_append(make<CachedBitmap>(bitmap_block_index, move(block)))) | ||||||
|  |         return ENOMEM; | ||||||
|     return m_cached_bitmaps.last(); |     return m_cached_bitmaps.last(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Brian Gianforcaro
						Brian Gianforcaro