On Sat, Oct 31, 2015 at 05:05:58PM +0300, Dmitry V. Levin wrote:
> On Sat, Oct 31, 2015 at 12:47:59AM -0400, Mike Frysinger wrote:
> > If the set of headers are unable to produce a valid list, printflags
> > will try to pass NULL to tprints which crashes.  Add a sanity check
> > for this edge case.
> > 
> > * util.c (printflags): Check xlat->str is not NULL.
> > ---
> >  util.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/util.c b/util.c
> > index c3e3fda..7c19044 100644
> > --- a/util.c
> > +++ b/util.c
> > @@ -353,8 +353,11 @@ printflags(const struct xlat *xlat, int flags, const 
> > char *dflt)
> >     const char *sep;
> >  
> >     if (flags == 0 && xlat->val == 0) {
> > -           tprints(xlat->str);
> > -           return 1;
> > +           if (xlat->str) {
> > +                   tprints(xlat->str);
> > +                   return 1;
> > +           } else
> > +                   return 0;
> >     }
> 
> Since callers expect that printflags will print something if dflt != NULL,
> I'd suggest adding xlat->str test right to the first condition instead.

I'm going to push the following edition of your fix, if you don't mind.

--- a/util.c
+++ b/util.c
@@ -357,7 +357,7 @@ printflags(const struct xlat *xlat, int flags, const char 
*dflt)
        int n;
        const char *sep;
 
-       if (flags == 0 && xlat->val == 0) {
+       if (flags == 0 && xlat->val == 0 && xlat->str) {
                tprints(xlat->str);
                return 1;
        }

-- 
ldv

Attachment: pgpJK2U3i6p6P.pgp
Description: PGP signature

------------------------------------------------------------------------------
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to