From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
"Hervé Poussineau" <hpoussin@reactos.org>
Subject: Re: [Qemu-devel] [PATCH] block/vvfat: Fix compiler warning with gcc 7
Date: Mon, 17 Jul 2017 17:57:19 +0200 [thread overview]
Message-ID: <20170717155719.GK5301@noname.redhat.com> (raw)
In-Reply-To: <20170717151207.24919-1-mreitz@redhat.com>
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 <mreitz@redhat.com>
Thanks, applied to the block branch.
Kevin
next prev parent reply other threads:[~2017-07-17 15:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 15:12 [Qemu-devel] [PATCH] block/vvfat: Fix compiler warning with gcc 7 Max Reitz
2017-07-17 15:22 ` Eric Blake
2017-07-17 15:57 ` Kevin Wolf [this message]
2017-07-17 18:40 ` Hervé Poussineau
2017-07-17 19:12 ` Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170717155719.GK5301@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=hpoussin@reactos.org \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.