Re: [PATCH 1/4] libmultipath: don't print garbage keywords

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2022-10-11 at 16:53 -0500, Benjamin Marzinski wrote:
> If snprint_keyword() failed to correctly set up sbuf, don't print it.
> Instead, return an error.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>

Reviewed-by: Martin Wilck <mwilck@xxxxxxxx>

> ---
>  libmpathutil/parser.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libmpathutil/parser.c b/libmpathutil/parser.c
> index 014d9b83..8d3ac53a 100644
> --- a/libmpathutil/parser.c
> +++ b/libmpathutil/parser.c
> @@ -152,7 +152,7 @@ int
>  snprint_keyword(struct strbuf *buff, const char *fmt, struct keyword
> *kw,
>                 const void *data)
>  {
> -       int r;
> +       int r = 0;
>         char *f;
>         struct config *conf;
>         STRBUF_ON_STACK(sbuf);
> @@ -190,8 +190,10 @@ snprint_keyword(struct strbuf *buff, const char
> *fmt, struct keyword *kw,
>                 }
>         } while (*fmt++);
>  out:
> -       return __append_strbuf_str(buff, get_strbuf_str(&sbuf),
> -                                  get_strbuf_len(&sbuf));
> +       if (r >= 0)
> +               r = __append_strbuf_str(buff, get_strbuf_str(&sbuf),
> +                                       get_strbuf_len(&sbuf));
> +       return r;
>  }
>  
>  static const char quote_marker[] = { '\0', '"', '\0' };

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux