lkml.org 
[lkml]   [2012]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Btrfs: avoid buffer overrun in mount option handling
On Wed, Apr 25, 2012 at 09:51:53PM +0200, Jim Meyering wrote:
>
> There is an off-by-one error: allocating room for a maximal result
> string but without room for a trailing NUL. That, can lead to
> returning a transformed string that is not NUL-terminated, and then
> to a caller reading beyond end of the malloc'd buffer.
>
> Worse still, we could write one non-NUL byte beyond the end of that
> malloc'd result buffer when given a mount option of "subvol=," (i.e.,
> no arg after the "=") because here the replacement "subvolid=0" is 3
> bytes longer, not just 2.

So this can't happen, since it would be caught by btrfs_parse_early_options
which expects subvolid=%d, and if it doesn't get that it would just error out,
so while adding another byte isn't bad, it's not correct either, so fix that and
I'd say it's good to go. Thanks,

Josef


\
 
 \ /
  Last update: 2012-04-25 22:37    [W:0.060 / U:1.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site