All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] dump: fix note_name_equal()
@ 2017-12-12 15:09 Marc-André Lureau
  2017-12-12 15:14 ` Laszlo Ersek
  2017-12-12 15:20 ` Andrew Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Marc-André Lureau @ 2017-12-12 15:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: drjones, lersek, Marc-André Lureau

Use the function argument "name" instead of hardcoded
"VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't
an exposed bug, thankfully.

Simplify a little bit the code while touching this.

Suggested-by: Andrew Jones <drjones@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 dump.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/dump.c b/dump.c
index d4a8c942eb..e9dfed060a 100644
--- a/dump.c
+++ b/dump.c
@@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,
     get_note_sizes(s, note, &head_size, &name_size, NULL);
     head_size = ROUND_UP(head_size, 4);
 
-    if (name_size != len ||
-        memcmp(note + head_size, "VMCOREINFO", len)) {
-        return false;
-    }
-
-    return true;
+    return name_size == len && memcmp(note + head_size, name, len) == 0;
 }
 
 /* write common header, sub header and elf note to vmcore */
-- 
2.15.1.355.g36791d7216

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] dump: fix note_name_equal()
  2017-12-12 15:09 [Qemu-devel] [PATCH] dump: fix note_name_equal() Marc-André Lureau
@ 2017-12-12 15:14 ` Laszlo Ersek
  2017-12-12 15:20 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Laszlo Ersek @ 2017-12-12 15:14 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: drjones

On 12/12/17 16:09, Marc-André Lureau wrote:
> Use the function argument "name" instead of hardcoded
> "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't
> an exposed bug, thankfully.
> 
> Simplify a little bit the code while touching this.
> 
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  dump.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/dump.c b/dump.c
> index d4a8c942eb..e9dfed060a 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,
>      get_note_sizes(s, note, &head_size, &name_size, NULL);
>      head_size = ROUND_UP(head_size, 4);
>  
> -    if (name_size != len ||
> -        memcmp(note + head_size, "VMCOREINFO", len)) {
> -        return false;
> -    }
> -
> -    return true;
> +    return name_size == len && memcmp(note + head_size, name, len) == 0;
>  }
>  
>  /* write common header, sub header and elf note to vmcore */
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] dump: fix note_name_equal()
  2017-12-12 15:09 [Qemu-devel] [PATCH] dump: fix note_name_equal() Marc-André Lureau
  2017-12-12 15:14 ` Laszlo Ersek
@ 2017-12-12 15:20 ` Andrew Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Jones @ 2017-12-12 15:20 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, lersek

On Tue, Dec 12, 2017 at 04:09:09PM +0100, Marc-André Lureau wrote:
> Use the function argument "name" instead of hardcoded
> "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't
> an exposed bug, thankfully.
> 
> Simplify a little bit the code while touching this.
> 
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  dump.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/dump.c b/dump.c
> index d4a8c942eb..e9dfed060a 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,
>      get_note_sizes(s, note, &head_size, &name_size, NULL);
>      head_size = ROUND_UP(head_size, 4);
>  
> -    if (name_size != len ||
> -        memcmp(note + head_size, "VMCOREINFO", len)) {
> -        return false;
> -    }
> -
> -    return true;
> +    return name_size == len && memcmp(note + head_size, name, len) == 0;
>  }
>  
>  /* write common header, sub header and elf note to vmcore */
> -- 
> 2.15.1.355.g36791d7216
>

Reviewed-by: Andrew Jones <drjones@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-12 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 15:09 [Qemu-devel] [PATCH] dump: fix note_name_equal() Marc-André Lureau
2017-12-12 15:14 ` Laszlo Ersek
2017-12-12 15:20 ` Andrew Jones

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.