qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: "Crístian Viana" <vianac@linux.vnet.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	aliguori@us.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/1 v4] Allow machines to configure the QEMU_VERSION that's exposed via hardware
Date: Wed, 23 May 2012 10:11:40 -0600	[thread overview]
Message-ID: <4FBD0C3C.1000505@redhat.com> (raw)
In-Reply-To: <4FBD0B85.4090605@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]

On 05/23/2012 10:08 AM, Crístian Viana wrote:

>> So when you posted the previous version of your patch it was pointed
>> out that this is a buffer overflow:
>> http://lists.gnu.org/archive/html/qemu-devel/2012-04/msg01657.html
>>
>> You need to fix this.
> 
> I have sent a reply to that thread explaining that the user actually
> doesn't have control of that string, that is only used internally in the
> code (just like the QEMU_VERSION macro).
> I fixed the code now with snprintf copying at most 12 chars to the
> string (the array size). I can't think of why pstrcat would be better in
> this case, as suggested by Erik.

s/Erik/Eric/, but you're not the first to make that typo.

pstrcat is more efficient than snprintf() - the former is dedicated to a
single task, while the latter has to parse a format string and decode
that it is doing a single %s expansion.  In other words, just because
*printf can do string concatenation doesn't make it the best tool for
the job.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

  reply	other threads:[~2012-05-23 16:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22 21:10 [Qemu-devel] [PATCH 1/1 v4] Allow machines to configure the QEMU_VERSION that's exposed via hardware Crístian Viana
2012-05-22 21:38 ` Peter Maydell
2012-05-23 16:08   ` Crístian Viana
2012-05-23 16:11     ` Eric Blake [this message]
2012-05-23 20:06       ` Crístian Viana
2012-05-23 20:54         ` Peter Maydell
2012-05-24 19:54           ` Crístian Viana

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=4FBD0C3C.1000505@redhat.com \
    --to=eblake@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vianac@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).