Skip to content

Commit

Permalink
erofs: Reject obviously bogus non-inline file sizes
Browse files Browse the repository at this point in the history
This avoids us trying to malloc() something ridiculous.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Sep 10, 2024
1 parent 114c2d5 commit 31c43f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libcomposefs/lcfs-writer-erofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,12 @@ static struct lcfs_node_s *lcfs_build_node_from_image(struct lcfs_image_data *da
// Filter only applies to toplevel
assert(filter == NULL);

// Reject obviously bogus file sizes
if (file_size > data->erofs_data_size) {
errno = EINVAL;
return NULL;
}

content = malloc(file_size);
if (content == NULL) {
errno = ENOMEM;
Expand Down

0 comments on commit 31c43f9

Please sign in to comment.