[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH] block/vvfat: Fix compiler warning with gcc 7

From: Kevin Wolf
Subject: Re: [Qemu-block] [PATCH] block/vvfat: Fix compiler warning with gcc 7
Date: Mon, 17 Jul 2017 17:57:19 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Am 17.07.2017 um 17:12 hat Max Reitz geschrieben:
> gcc 7 complains that the sprintf() might write a null byte beyond the
> end of the tail buffer.  That is wrong, but we can silence it by making
> i unsigned (it can never be negative anyway, see the if condition right
> before).  For some reason, this allows gcc to suddenly accurately
> calculate the range of i so we can give the tail[] array the exact size
> it needs to have (which is 8 bytes) without gcc complaining.
> In addition, let us convert the sprintf() to snprintf(), because that is
> always nicer, and add an assertion about the range of the return value
> afterwards so we can see that "8 - len" will never be negative and thus
> "entry->name + MIN(j, 8 - len)" will never be out of bounds.
> Signed-off-by: Max Reitz <address@hidden>

Thanks, applied to the block branch.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]