dhcpcd-discuss

RE: Segment Fault in find_route

Walrath, Paul (Vancouver)

Sat Apr 11 01:00:54 2015

Hi Roy,

I tried the code change and the segment fault went away.  Should I enter a ticket for this?

Paul

From: Walrath, Paul (Vancouver)
Sent: Friday, April 10, 2015 5:20 PM
To: dhcpcd-discuss@xxxxxxxxxxxx
Subject: [dhcpcd-discuss] Segment Fault in find_route

Hi Roy,

I've been seeing an occasional segment fault in the find_route() function.  In the following code, a zero value pointer is being dereferenced.

#ifdef HAVE_ROUTE_METRIC
            (srt || (!rt->iface ||
            rt->iface->metric == r->iface->metric)) &&
#endif

The r->iface value is 0, so r->iface->metric is causing the segment fault.  This would be avoided by the following:

#ifdef HAVE_ROUTE_METRIC
            (srt || (!rt->iface || !r->iface ||
            rt->iface->metric == r->iface->metric)) &&
#endif

This is similar to what is implemented in find_route6()


#ifdef HAVE_ROUTE_METRIC

            (r->iface == NULL || rt->iface == NULL ||

            rt->iface->metric == r->iface->metric) &&

#endif

Does this look right to you?  I don't have any idea if this breaks the logic in the function.

I am looking at trunk source code which I cloned last week.  I hope it's not too far out of date.

Paul Walrath
Hewlett-Packard



References:
Segment Fault in find_routeWalrath, Paul (Vancouver)
Archive administrator: postmaster@marples.name