Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140905180252.GO23797@brightrain.aerifal.cx>
Date: Fri, 5 Sep 2014 14:02:52 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: New static analysis results

On Thu, Sep 04, 2014 at 01:13:58PM -0400, Rich Felker wrote:
> On Thu, Sep 04, 2014 at 08:45:45PM +0400, Alexander Monakov wrote:
> > Hello,
> > 
> > I'm happy to report a few new results from running static code analysis on
> > musl (from a tool developed where I work).
> > 
> > ctime.c:5
> >     localtime(t) may return NULL, but that will cause UB in asctime
> 
> Yes, I need to look into what ctime should do in this case though...

Found it:

  7.27.3.2 The ctime function

  2 The ctime function converts the calendar time pointed to by timer
  to local time in the form of a string. It is equivalent to

           asctime(localtime(timer))

The standard basically specifies the implementation, so it's clearly
UB if localtime(t) would return a null pointer. Looks like no action
is needed here; the most-desirable-behavior (crash) for UB happens
automatically anyway.

> > regexec.c:253
> >     "return REG_NOMATCH;" in GET_NEXT_WCHAR leaks memory allocated for 'buf'
> 
> This should be checked, but it sounds likely.

nsz is looking into fixing it.

> > lookup_serv.c:55
> > getnameinfo.c:99
> >     pointless "if (!p) continue;" when "if (!*p) continue;" was probably
> >     intended
> 
> I'd have to look at the code but it's possible the intent was leftover
> from old code that was changed rather than being what you think. But I
> think your proposed change is probably right for the current code.
> Looks low-priority anyway (only affects parsing invalid hosts/services
> files).

Digging up the history was confusing so I'm just fixing them based on
the current code.

For lookup_serv.c, the line was a nop and is not needed. For
getnameinfo.c it seems to be an actual bug that could cause reading
past the end of the line buffer (but not write).

> > fpathconf.c
> >     off-by-one error in range check (if (name >= sizeof ...))
> 
> Indeed. This should be fixed.

Fixing.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.