qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Mark Nelson <mdnelson8@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, richard.henderson@linaro.org
Subject: Re: [PATCH] util/guest-random: Fix size arg to tail memcpy
Date: Fri, 9 Jul 2021 18:28:00 +0200	[thread overview]
Message-ID: <d509a8ee-ffd4-e71d-a1af-852c454759d0@vivier.eu> (raw)
In-Reply-To: <20210709120600.11080-1-mdnelson8@gmail.com>

Le 09/07/2021 à 14:06, Mark Nelson a écrit :
> We know that in the body of this if statement i is less than len, so
> we really should be copying len - i bytes not i - len bytes.
> 
> Fix this typo.
> 
> Signed-off-by: Mark Nelson <mdnelson8@gmail.com>
> ---
>  util/guest-random.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/util/guest-random.c b/util/guest-random.c
> index 086115bd67..23643f86cc 100644
> --- a/util/guest-random.c
> +++ b/util/guest-random.c
> @@ -38,7 +38,7 @@ static int glib_random_bytes(void *buf, size_t len)
>      }
>      if (i < len) {
>          x = g_rand_int(rand);
> -        __builtin_memcpy(buf + i, &x, i - len);
> +        __builtin_memcpy(buf + i, &x, len - i);
>      }
>      return 0;
>  }
> 

Applied to my trivial-patches branch.

Thanks,
Laurent


      parent reply	other threads:[~2021-07-09 16:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 12:06 [PATCH] util/guest-random: Fix size arg to tail memcpy Mark Nelson
2021-07-09 14:54 ` Richard Henderson
2021-07-09 16:07 ` Philippe Mathieu-Daudé
2021-07-09 16:28 ` Laurent Vivier [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=d509a8ee-ffd4-e71d-a1af-852c454759d0@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=mdnelson8@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=richard.henderson@linaro.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 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).