summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2025-04-28 13:53:40 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-04-28 13:55:05 +0200
commit88cfa0464dc86d088e0f8484bc15a279d83919e9 (patch)
tree8d8d8bb24438cc8feae430fa6ecc89c4c99e073d
parent8c4b37178c8e7cfcbb37682180c697cb6e55cb34 (diff)
ext2fs: fix crash on ENOSPC
54c0b9b9dbf7 ("ext2fs: Trap trying to access bogus data areas") added checks on the allocated block number, but did not take care of the out-of-space condition, which callers of ext2_new_block and ext2_alloc_block know to handle.
-rw-r--r--ext2fs/balloc.c5
-rw-r--r--ext2fs/getblk.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c
index 231ab589..0957f19e 100644
--- a/ext2fs/balloc.c
+++ b/ext2fs/balloc.c
@@ -407,8 +407,9 @@ got_block:
alloc_sync (0);
/* Trap trying to allocate superblock, block group descriptor table, or beyond the end */
- assert_backtrace (j >= group_desc_block_end
- && j < store->size >> log2_block_size);
+ assert_backtrace (j == 0 ||
+ (j >= group_desc_block_end
+ && j < store->size >> log2_block_size));
return j;
}
diff --git a/ext2fs/getblk.c b/ext2fs/getblk.c
index 26ac145e..ed6e3e09 100644
--- a/ext2fs/getblk.c
+++ b/ext2fs/getblk.c
@@ -100,8 +100,9 @@ ext2_alloc_block (struct node *node, block_t goal, int zero)
}
/* Trap trying to allocate superblock, block group descriptor table, or beyond the end */
- assert_backtrace (result >= group_desc_block_end
- && result < store->size >> log2_block_size);
+ assert_backtrace (result == 0 ||
+ (result >= group_desc_block_end
+ && result < store->size >> log2_block_size));
#else
result = ext2_new_block (goal, 0, 0);
#endif