|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From f414a269b378d526b8b26c5b52743360b43965ce Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Tom Gundersen <teg@jklm.no>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 17 Sep 2014 19:00:55 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] networkd: dhcp4 - fix unchecked return value
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Found by coverity. CID #1237529 and #1237528.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/network/networkd-dhcp4.c | 19 +++++++++++--------
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 11 insertions(+), 8 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index e0b3acad1b..e451af8643 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/network/networkd-dhcp4.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/network/networkd-dhcp4.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -178,7 +178,7 @@ static int dhcp_lease_lost(Link *link) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct in_addr addr;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct in_addr netmask;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
struct in_addr gateway;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- unsigned prefixlen;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ unsigned prefixlen = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
assert(link);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -237,15 +237,18 @@ static int dhcp_lease_lost(Link *link) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sd_dhcp_lease_get_address(link->dhcp_lease, &addr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- sd_dhcp_lease_get_netmask(link->dhcp_lease, &netmask);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- prefixlen = in_addr_netmask_to_prefixlen(&netmask);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = sd_dhcp_lease_get_address(link->dhcp_lease, &addr);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r >= 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ r = sd_dhcp_lease_get_netmask(link->dhcp_lease, &netmask);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (r >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ prefixlen = in_addr_netmask_to_prefixlen(&netmask);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- address->family = AF_INET;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- address->in_addr.in = addr;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- address->prefixlen = prefixlen;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ address->family = AF_INET;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ address->in_addr.in = addr;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ address->prefixlen = prefixlen;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- address_drop(address, link, &link_address_drop_handler);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ address_drop(address, link, &link_address_drop_handler);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (link->network->dhcp_mtu) {
|