From: Amit Shah <amit.shah@redhat.com>
To: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
Cc: qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/1] Add qemu_get_counted_string to read a string prefixed by a count byte
Date: Wed, 20 May 2015 12:36:50 +0530 [thread overview]
Message-ID: <20150520070650.GH15452@grmbl.mre> (raw)
In-Reply-To: <1431703178-12112-1-git-send-email-dgilbert@redhat.com>
On (Fri) 15 May 2015 [16:19:38], Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> and use it in loadvm_state and ram_load.
>
> Where ever it's used, check the return and error if it failed.
>
> Minor: ram_load was using a 257 byte array for its string, the
> maximum length is 255 bytes + 0 terminator, so fix to 256
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
(snip)
> +/*
> + * Get a string whose length is determined by a single preceding byte
> + * A preallocated 256 byte buffer must be passed in.
> + * Returns: len on success and a 0 terminated string in the buffer
> + * else 0
> + * (Note a 0 length string will return 0 either way)
> + */
> +size_t qemu_get_counted_string(QEMUFile *f, char buf[256])
> +{
> + size_t len = qemu_get_byte(f);
> + size_t res = qemu_get_buffer(f, (uint8_t *)buf, len);
> +
> + buf[len] = 0;
For safety, let's use
buf[res] = 0; here...
Amit
prev parent reply other threads:[~2015-05-20 7:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-15 15:19 [Qemu-devel] [PATCH 1/1] Add qemu_get_counted_string to read a string prefixed by a count byte Dr. David Alan Gilbert (git)
2015-05-20 7:06 ` Amit Shah [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=20150520070650.GH15452@grmbl.mre \
--to=amit.shah@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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).