chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ff02f10
)
networkd: dhcp4 - fix unchecked return value
author
Tom Gundersen
<teg@jklm.no>
Wed, 17 Sep 2014 17:00:55 +0000
(19:00 +0200)
committer
Tom Gundersen
<teg@jklm.no>
Wed, 17 Sep 2014 17:13:35 +0000
(19:13 +0200)
Found by coverity. CID #
1237529
and #
1237528
.
src/network/networkd-dhcp4.c
patch
|
blob
|
history
diff --git
a/src/network/networkd-dhcp4.c
b/src/network/networkd-dhcp4.c
index e0b3acad1b8ede49512bc337519693dc89e032fd..e451af86433b84e3204a3319adc5a9fffb9eacaa 100644
(file)
--- a/
src/network/networkd-dhcp4.c
+++ b/
src/network/networkd-dhcp4.c
@@
-178,7
+178,7
@@
static int dhcp_lease_lost(Link *link) {
struct in_addr addr;
struct in_addr netmask;
struct in_addr gateway;
struct in_addr addr;
struct in_addr netmask;
struct in_addr gateway;
- unsigned prefixlen;
+ unsigned prefixlen
= 0
;
int r;
assert(link);
int r;
assert(link);
@@
-237,15
+237,18
@@
static int dhcp_lease_lost(Link *link) {
}
}
}
}
- sd_dhcp_lease_get_address(link->dhcp_lease, &addr);
- sd_dhcp_lease_get_netmask(link->dhcp_lease, &netmask);
- prefixlen = in_addr_netmask_to_prefixlen(&netmask);
+ r = sd_dhcp_lease_get_address(link->dhcp_lease, &addr);
+ if (r >= 0) {
+ r = sd_dhcp_lease_get_netmask(link->dhcp_lease, &netmask);
+ if (r >= 0)
+ prefixlen = in_addr_netmask_to_prefixlen(&netmask);
- address->family = AF_INET;
- address->in_addr.in = addr;
- address->prefixlen = prefixlen;
+
address->family = AF_INET;
+
address->in_addr.in = addr;
+
address->prefixlen = prefixlen;
- address_drop(address, link, &link_address_drop_handler);
+ address_drop(address, link, &link_address_drop_handler);
+ }
}
if (link->network->dhcp_mtu) {
}
if (link->network->dhcp_mtu) {