Skip to content

Commit

Permalink
tunnel: Fix uninitialized struct on stack
Browse files Browse the repository at this point in the history
Some `struct tunnel` sub-properties may be read whereas the structure is
not initialized, like in `ipv4.c`:

  sprintf(env_var, "VPN_ROUTE_DEST_%d", tunnel->ipv4.split_routes);

This commits `memset`s the structure to zero to avoid strange
behaviours.

Thanks to @mata-p for finding this out.

Fixes: #55
  • Loading branch information
adrienverge committed May 21, 2016
1 parent da745e7 commit dc7d547
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ int run_tunnel(struct vpn_config *config)
int ret;
struct tunnel tunnel;

memset(&tunnel, 0, sizeof(tunnel));
tunnel.config = config;
tunnel.on_ppp_if_up = on_ppp_if_up;
tunnel.on_ppp_if_down = on_ppp_if_down;
Expand Down

0 comments on commit dc7d547

Please sign in to comment.