All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-trivial] [PATCH 5/7] cutils: refine strtol error handling in parse_debug_env
Date: Sat, 07 Feb 2015 11:52:02 +0300	[thread overview]
Message-ID: <54D5D232.3070308@msgid.tls.msk.ru> (raw)
In-Reply-To: <1422270747-23994-6-git-send-email-pbonzini@redhat.com>

26.01.2015 14:12, Paolo Bonzini wrote:
> Avoid truncation of a 64-bit long to a 32-bit int, and check for errno
> (especially ERANGE).
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  util/cutils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util/cutils.c b/util/cutils.c
> index dbe7412..f227064 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -523,7 +523,7 @@ int parse_debug_env(const char *name, int max, int initial)
>  {
>      char *debug_env = getenv(name);
>      char *inv = NULL;
> -    int debug;
> +    long debug;
>  
>      if (!debug_env) {
>          return initial;
> @@ -532,7 +532,7 @@ int parse_debug_env(const char *name, int max, int initial)
>      if (inv == debug_env) {
>          return initial;
>      }
> -    if (debug < 0 || debug > max) {
> +    if (debug < 0 || debug > max || errno != 0) {

It is not really right to check errno without (re)setting it
before call to strtol().

Thanks,

/mjt


WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 5/7] cutils: refine strtol error handling in parse_debug_env
Date: Sat, 07 Feb 2015 11:52:02 +0300	[thread overview]
Message-ID: <54D5D232.3070308@msgid.tls.msk.ru> (raw)
In-Reply-To: <1422270747-23994-6-git-send-email-pbonzini@redhat.com>

26.01.2015 14:12, Paolo Bonzini wrote:
> Avoid truncation of a 64-bit long to a 32-bit int, and check for errno
> (especially ERANGE).
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  util/cutils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/util/cutils.c b/util/cutils.c
> index dbe7412..f227064 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -523,7 +523,7 @@ int parse_debug_env(const char *name, int max, int initial)
>  {
>      char *debug_env = getenv(name);
>      char *inv = NULL;
> -    int debug;
> +    long debug;
>  
>      if (!debug_env) {
>          return initial;
> @@ -532,7 +532,7 @@ int parse_debug_env(const char *name, int max, int initial)
>      if (inv == debug_env) {
>          return initial;
>      }
> -    if (debug < 0 || debug > max) {
> +    if (debug < 0 || debug > max || errno != 0) {

It is not really right to check errno without (re)setting it
before call to strtol().

Thanks,

/mjt

  reply	other threads:[~2015-02-07  8:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 11:12 [Qemu-trivial] [PATCH 0/7] Six coverity fixes and a cleanup Paolo Bonzini
2015-01-26 11:12 ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 1/7] cpu-exec: drop dead assignment Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 2/7] cpu-exec: simplify icount code Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 3/7] uri: avoid NULL arguments to strcmp Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 4/7] qemu-sockets: improve error reporting in unix_listen_opts Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 5/7] cutils: refine strtol error handling in parse_debug_env Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-02-07  8:52   ` Michael Tokarev [this message]
2015-02-07  8:52     ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 6/7] aes: remove a dead return statement Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 11:12 ` [Qemu-trivial] [PATCH 7/7] migration: do floating-point division Paolo Bonzini
2015-01-26 11:12   ` [Qemu-devel] " Paolo Bonzini
2015-01-26 18:06   ` [Qemu-trivial] " Dr. David Alan Gilbert
2015-01-26 18:06     ` Dr. David Alan Gilbert
2015-01-26 18:15     ` [Qemu-trivial] " Juan Quintela
2015-01-26 18:15       ` [Qemu-devel] " Juan Quintela
2015-02-07  9:00 ` [Qemu-trivial] [PATCH 0/7] Six coverity fixes and a cleanup Michael Tokarev
2015-02-07  9:00   ` [Qemu-devel] " Michael Tokarev
2015-02-07 20:01   ` Paolo Bonzini
2015-02-07 20:01     ` [Qemu-devel] " Paolo Bonzini
2015-02-07 20:39     ` Michael Tokarev
2015-02-07 20:39       ` [Qemu-devel] " Michael Tokarev
2015-02-09 12:17     ` Juan Quintela
2015-02-09 12:17       ` [Qemu-devel] " Juan Quintela

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=54D5D232.3070308@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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 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.