qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] Improve error handling in do_snapshot_blkdev()
Date: Thu, 03 Mar 2011 14:10:28 +0100	[thread overview]
Message-ID: <4D6F9344.40001@redhat.com> (raw)
In-Reply-To: <AANLkTinXxjGvx6KnsU+_VP5j_nLMzWBAX1-g_u9mv6bF@mail.gmail.com>

On 03/03/11 14:06, Stefan Hajnoczi wrote:
> On Thu, Mar 3, 2011 at 10:44 AM,  <Jes.Sorensen@redhat.com> wrote:
>> +    char old_filename[1024];
>> +
>> +    old_filename[1023] = '\0';
>>
>>     if (!filename) {
>>         qerror_report(QERR_MISSING_PARAMETER, "snapshot_file");
>> @@ -591,6 +594,10 @@ int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data)
>>         goto out;
>>     }
>>
>> +    strncpy(old_filename, bs->filename, 1024);
> 
> strncpy does not NUL-terminate if you reach the maximum length.  The
> source buffer is 1024 chars so we should be fine unless there is a bug
> somewhere else too, but please move the old_filename[1023] = '\0'
> after the strncpy and use sizeof(old_filename) as the maximum instead
> of 1024.

Good point, I was trying to catch it but got it backwards :(

Cheers,
Jes

      reply	other threads:[~2011-03-03 13:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-03 10:44 [Qemu-devel] [PATCH] Improve error handling in do_snapshot_blkdev() Jes.Sorensen
2011-03-03 13:06 ` Stefan Hajnoczi
2011-03-03 13:10   ` Jes Sorensen [this message]

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=4D6F9344.40001@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@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).