summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-04-08 21:26:19 +0200
committerTom Gundersen <teg@jklm.no>2014-04-08 21:26:19 +0200
commit7ff8f4b53c158833b87899090552b18c922596de (patch)
treed8f491ce1315f038f317710719008b213b16e3d3 /src/network
parentaa6fc9b8c823834f262ab5ab2ac094a3775370a9 (diff)
networkd: guard against NULL pointers
This should never be a problem, but better be safe than sorry.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 63d253d941..f076525539 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1299,6 +1299,7 @@ static int link_getlink_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
int r;
assert(link);
+ assert(link->ifname);
if (link->state == LINK_STATE_FAILED)
return 1;
@@ -1510,11 +1511,16 @@ int link_update(Link *link, sd_rtnl_message *m) {
int link_save(Link *link) {
_cleanup_free_ char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
+ const char *state;
int r;
assert(link);
assert(link->state_file);
+ state = link_state_to_string(link->state);
+ if (!state)
+ goto finish;
+
r = fopen_temporary(link->state_file, &f, &temp_path);
if (r < 0)
goto finish;
@@ -1523,8 +1529,7 @@ int link_save(Link *link) {
fprintf(f,
"# This is private data. Do not parse.\n"
- "STATE=%s\n",
- link_state_to_string(link->state));
+ "STATE=%s\n", state);
if (link->dhcp_lease) {
_cleanup_free_ char *lease_file = NULL;