Skip to content

Commit 45d5e08

Browse files
在fat的resize中加入最大容量检查
1 parent da98a83 commit 45d5e08

File tree

1 file changed

+4
-0
lines changed
  • kernel/src/filesystem/fat

1 file changed

+4
-0
lines changed

kernel/src/filesystem/fat/fs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,10 @@ impl IndexNode for LockedFATInode {
17401740
Ok(())
17411741
}
17421742
fn resize(&self, len: usize) -> Result<(), SystemError> {
1743+
//检查是否超过fat支持的最大容量
1744+
if (len as u64) > MAX_FILE_SIZE {
1745+
return Err(SystemError::EFBIG);
1746+
}
17431747
// 先调整页缓存:清除被截断区间的缓存页,再缩容缓存大小
17441748
if let Some(page_cache) = self.page_cache() {
17451749
let start_page = (len + MMArch::PAGE_SIZE - 1) >> MMArch::PAGE_SHIFT;

0 commit comments

Comments
 (0)