[dm-devel] [PATCH] add_feature: coredump

huang.wei56 at zte.com.cn huang.wei56 at zte.com.cn
Mon Oct 17 02:37:56 UTC 2016


If no features are present, the function will return from the case "if (!n 
|| *n == '0')" ( structs.c line 521) . 

Because add_feature() is called by some functions, taking a protect inside 
is much safer.
 




Hannes Reinecke <hare at suse.de> 
2016-10-14 14:02

收件人
huang.wei56 at zte.com.cn, Christophe Varoqui 
<christophe.varoqui at opensvc.com>, 
抄送
bmarzins at redhat.com, dm-devel at redhat.com, zhang.kai16 at zte.com.cn, 
tang.junhui at zte.com.cn
主题
Re: [PATCH] add_feature: coredump






On 10/14/2016 04:08 AM, huang.wei56 at zte.com.cn wrote:
> From: "wei.huang" <huang.wei56 at zte.com.cn>
> 
> Problem:
> when we configure device like vendor is COMPELNT in multipath.conf, 
multipathd will be coredump.
> 
> Reasons:
> some vonders are not configured features in default_hw. In add_feature, 
strstr's first parameter *f maybe null.
> 
> Signed-off-by: wei.huang <huang.wei56 at zte.com.cn>
> ---
>  libmultipath/structs.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libmultipath/structs.c b/libmultipath/structs.c
> index fee58e5..41e142f 100644
> --- a/libmultipath/structs.c
> +++ b/libmultipath/structs.c
> @@ -520,6 +520,20 @@ add_feature (char **f, char *n)
>                if (!n || *n == '0')
>                                return 0;
> 
> +              /* default feature is null */
> +              if(!*f)
> +              {
> +                              l = strlen("1 ") + strlen(n) + 1;
> +                              t = MALLOC(l);
> +                              if (!t)
> +                                              return 1;
> +
> +                              snprintf(t, l, "1 %s", n);
> +                              *f = t;
> + 
> +                              return 0;
> +              }
> +
>                /* Check if feature is already present */
>                if (strstr(*f, n))
>                                return 0;
> 
No, that is wrong.
It'll insert a '1' into the string if no features are present.

I have a patch queued for fixing this one up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                                 Teamlead Storage & 
Networking
hare at suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/dm-devel/attachments/20161017/04f42f44/attachment.htm>


More information about the dm-devel mailing list