Mercurial > hg > dhcpcd
changeset 4607:8e54887526a6 draft dhcpcd-8.0.2
routes: Fix a NULL dereference error for global static routes
No idea why you would want them, but just in case .....
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Tue, 30 Jul 2019 11:04:24 +0100 |
| parents | 88476f3f04d0 |
| children | 3aef2b50ef03 |
| files | src/dhcpcd.c src/if-options.c |
| diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcpcd.c Tue Jul 30 10:29:51 2019 +0100 +++ b/src/dhcpcd.c Tue Jul 30 11:04:24 2019 +0100 @@ -2125,13 +2125,13 @@ } free(ctx.ifaces); } + free_options(&ctx, ifo); #ifdef HAVE_OPEN_MEMSTREAM if (ctx.script_fp) fclose(ctx.script_fp); #endif free(ctx.script_buf); free(ctx.script_env); - free_options(&ctx, ifo); rt_dispose(&ctx); free(ctx.duid); if (ctx.link_fd != -1) {
--- a/src/if-options.c Tue Jul 30 10:29:51 2019 +0100 +++ b/src/if-options.c Tue Jul 30 11:04:24 2019 +0100 @@ -2612,6 +2612,7 @@ { size_t i; #ifdef RT_FREE_ROUTE_TABLE + struct interface *ifp; struct rt *rt; #endif struct dhcp_opt *opt; @@ -2640,9 +2641,12 @@ /* Stupidly, we don't know the interface when creating the options. * As such, make sure each route has one so they can goto the * free list. */ - RB_TREE_FOREACH(rt, &ifo->routes) { - if (rt->rt_ifp == NULL) - rt->rt_ifp = TAILQ_FIRST(ctx->ifaces); + ifp = ctx->ifaces != NULL ? TAILQ_FIRST(ctx->ifaces) : NULL; + if (ifp != NULL) { + RB_TREE_FOREACH(rt, &ifo->routes) { + if (rt->rt_ifp == NULL) + rt->rt_ifp = ifp; + } } #endif rt_headclear0(ctx, &ifo->routes, AF_UNSPEC);
