From: Martin Wilck <mwilck@suse.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>,
Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH 4/4] multipath: Fix a potential buffer overflow
Date: Tue, 13 Jun 2017 21:28:43 +0200 [thread overview]
Message-ID: <1497382123.4654.48.camel@suse.com> (raw)
In-Reply-To: <20170613163339.23005-5-bart.vanassche@sandisk.com>
Hi Bart,
On Tue, 2017-06-13 at 09:33 -0700, Bart Van Assche wrote:
> Avoid that gcc 7 reports the following warning:
>
> cli_handlers.c:1340:18: warning: '%d' directive writing between 1 and
> 3 bytes into a region of size 2 [-Wformat-overflow=]
> sprintf(*reply,"%d",mpp->prflag);
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> ---
> multipathd/cli_handlers.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
> index 04c73866..460fea1f 100644
> --- a/multipathd/cli_handlers.c
> +++ b/multipathd/cli_handlers.c
> @@ -1,6 +1,9 @@
> /*
> * Copyright (c) 2005 Christophe Varoqui
> */
> +
> +#define _GNU_SOURCE
> +
> #include "checkers.h"
> #include "memory.h"
> #include "vector.h"
> @@ -1332,14 +1335,9 @@ cli_getprstatus (void * v, char ** reply, int
> * len, void * data)
>
> condlog(3, "%s: prflag = %u", param, (unsigned int)mpp-
> >prflag);
>
> - *reply =(char *)malloc(2);
> - *len = 2;
> - memset(*reply,0,2);
> -
> -
> - sprintf(*reply,"%d",mpp->prflag);
> - (*reply)[1]='\0';
> -
> + *len = asprintf(reply, "%d", mpp->prflag);
> + if (*len < 0)
> + return 1;
>
> condlog(3, "%s: reply = %s", param, *reply);
>
how about this simpler patch, as prflag is actually a boolean?
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 04c73866..c31ebd34 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1337,7 +1337,7 @@ cli_getprstatus (void * v, char ** reply, int * len, void * data)
memset(*reply,0,2);
- sprintf(*reply,"%d",mpp->prflag);
+ sprintf(*reply, "%d", !!mpp->prflag);
(*reply)[1]='\0';
--
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2017-06-13 19:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-13 16:33 [PATCH 0/4] Four multipath-tools patches Bart Van Assche
2017-06-13 16:33 ` [PATCH 1/4] kpartx: Improve portability of set_loop() Bart Van Assche
2017-06-13 19:33 ` Martin Wilck
2017-06-13 16:33 ` [PATCH 2/4] libmultipath: Simplify assemble_map() Bart Van Assche
2017-06-13 19:32 ` Martin Wilck
2017-06-13 16:33 ` [PATCH 3/4] libmultipath/datacore: Remove dead code Bart Van Assche
2017-06-13 19:31 ` Martin Wilck
2017-06-13 16:33 ` [PATCH 4/4] multipath: Fix a potential buffer overflow Bart Van Assche
2017-06-13 19:28 ` Martin Wilck [this message]
2017-06-13 19:53 ` Bart Van Assche
2017-06-13 20:18 ` Martin Wilck
2017-06-13 20:21 ` Bart Van Assche
2017-06-13 20:35 ` Martin Wilck
2017-06-21 10:16 ` [PATCH 0/4] Four multipath-tools patches Christophe Varoqui
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=1497382123.4654.48.camel@suse.com \
--to=mwilck@suse.com \
--cc=bart.vanassche@sandisk.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@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 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.