dhcpcd-discuss

null pointer dereference using routers= option

Duncan Overbruck

Sat Aug 17 22:57:03 2019

Hello,

I received a bug report and a backtrace for dhcpcd version 8.0.2.

When the `routers` (and probably a few other ones like `routes`) option is used,
the route is created and dereferences NULL, when rt_ifp->carrier is used to
compare routes.

Here is the backtrace:

#0  rt_compare_proto (context=<optimized out>, node1=0x5587a2c33430, node2=0x5587a2c33ae0) at route.c:154
154     route.c: No such file or directory.
(gdb) bt
#0  rt_compare_proto (context=<optimized out>, node1=0x5587a2c33430, node2=0x5587a2c33ae0) at route.c:154
#1  0x00005587a0fc2b62 in rb_tree_insert_node (rbt=rbt@entry=0x5587a2c4c120, object=object@entry=0x5587a2c33ae0) at ../compat/rb.c:208
#2  0x00005587a0fa0943 in rt_proto_add_ctx (tree=tree@entry=0x5587a2c4c120, rt=rt@entry=0x5587a2c33ae0, ctx=ctx@entry=0x7ffd6f7da710) at route.c:373
#3  0x00005587a0f9e1a2 in parse_option (ctx=ctx@entry=0x7ffd6f7da710, ifname=ifname@entry=0x5587a2c347e8 "eth0", ifo=ifo@entry=0x5587a2c3c040, opt=<optimized out>, arg=<optimized out>, ldop=<optimized out>, edop=0x7ffd6f7da528)
    at if-options.c:1145
#4  0x00005587a0f9ed2e in parse_config_line (ctx=ctx@entry=0x7ffd6f7da710, ifname=ifname@entry=0x5587a2c347e8 "eth0", ifo=ifo@entry=0x5587a2c3c040, opt=<optimized out>, line=0x5587a2c28f17 "routers=192.168.16.254",
	    ldop=ldop@entry=0x7ffd6f7da520, edop=<optimized out>) at if-options.c:2206
#5  0x00005587a0f9f6be in read_config (ctx=0x7ffd6f7da710, ifname=0x5587a2c347e8 "eth0", ssid=0x7ffd6f7da610 "", profile=0x0) at if-options.c:2560
#6  0x00005587a0f95e2b in dhcpcd_selectprofile (ifp=0x5587a2c347d0, profile=0x0) at dhcpcd.c:613
#7  0x00005587a0f96007 in configure_interface (ifp=0x5587a2c347d0, argc=3, argv=0x7ffd6f7daae8, options=0) at dhcpcd.c:641
#8  0x00005587a0f96049 in dhcpcd_initstate1 (ifp=0x5587a2c347d0, argc=<optimized out>, argv=<optimized out>, options=0) at dhcpcd.c:688
#9  0x00005587a0f92fbe in main (argc=3, argv=0x7ffd6f7daae8) at dhcpcd.c:2044

And here is the relevant part of the used configuration:

interface eth0
# Home and work networks, with static IPs:
static ip_address=192.168.16.101
static routers=192.168.16.254

Greetings,
Duncan Overbruck

Follow-Ups:
Re: null pointer dereference using routers= optionRoy Marples
Archive administrator: postmaster@marples.name