Messages in this thread | | | Date | Wed, 19 Jul 2023 09:03:29 -0400 | From | Bob Copeland <> | Subject | Re: [PATCH][next] fs: omfs: Use flexible-array member in struct omfs_extent |
| |
On Mon, Jul 17, 2023 at 08:20:22AM -0700, Kees Cook wrote: > > @@ -14,7 +14,7 @@ static u32 omfs_max_extents(struct omfs_sb_info *sbi, int offset) > > { > > return (sbi->s_sys_blocksize - offset - > > sizeof(struct omfs_extent)) / > > - sizeof(struct omfs_extent_entry) + 1; > > + sizeof(struct omfs_extent_entry); > > } > > I think the original calculation meant to do: > > return (sbi->s_sys_blocksize - offset - > (sizeof(struct omfs_extent) - sizeof(struct omfs_extent_entry))) / > sizeof(struct omfs_extent_entry);
I can confirm the intent. I also went back and looked at the usages just to be sure.
In this case, there are two possible values for x = s_sys_blocksize - offset: 7728 or 8128, and both can be divided by 16 evenly so you have either:
f_old = (x - 32) / 16 + 1 or: f_new = (x - 16) / 16
they both simplify to x/16 - 1 so they are equivalent for these inputs.
-- Bob Copeland %% https://bobcopeland.com/
| |