Commit 6c9a3f84 authored by Colin Ian King's avatar Colin Ian King Committed by Linus Torvalds

fs/hfs/extent.c: fix array out of bounds read of array extent

Currently extent and index i are both being incremented causing an array
out of bounds read on extent[i].  Fix this by removing the extraneous
increment of extent.

Ernesto said:

: This is only triggered when deleting a file with a resource fork.  I
: may be wrong because the documentation isn't clear, but I don't think
: you can create those under linux.  So I guess nobody was testing them.
: > A disk space leak, perhaps?
: That's what it looks like in general.  hfs_free_extents() won't do
: anything if the block count doesn't add up, and the error will be
: ignored.  Now, if the block count randomly does add up, we could see
: some corruption.

Detected by CoverityScan, CID#711541 ("Out of bounds read")

Link: default avatarColin Ian King <>
Reviewed-by: default avatarErnesto A. Fernndez <>
Cc: David Howells <>
Cc: Al Viro <>
Cc: Hin-Tak Leung <>
Cc: Vyacheslav Dubeyko <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 8cd3cb50
......@@ -304,7 +304,7 @@ int hfs_free_fork(struct super_block *sb, struct hfs_cat_file *file, int type)
return 0;
blocks = 0;
for (i = 0; i < 3; extent++, i++)
for (i = 0; i < 3; i++)
blocks += be16_to_cpu(extent[i].count);
res = hfs_free_extents(sb, extent, blocks, blocks);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment