From d9bf4f8c6c47b8620ffa1a056208eb15118b78d5 Mon Sep 17 00:00:00 2001 From: Umut Tezduyar Lindskog Date: Sun, 27 Apr 2014 21:58:26 +0200 Subject: libnetworkd: add link local tests - Also only allow positive ifindex on both dhcp and ipv4ll [tomegun: the kernel always sets a positive ifindex, but some APIs accept ifindex=0 with various meanings, so we should protect against accidentally passing ifindex=0 along.] --- src/libsystemd-network/sd-ipv4ll.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/libsystemd-network/sd-ipv4ll.c') diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c index 72289b2baf..fd39c12eb2 100644 --- a/src/libsystemd-network/sd-ipv4ll.c +++ b/src/libsystemd-network/sd-ipv4ll.c @@ -382,7 +382,7 @@ static int ipv4ll_receive_message(sd_event_source *s, int fd, int sd_ipv4ll_set_index(sd_ipv4ll *ll, int interface_index) { assert_return(ll, -EINVAL); - assert_return(interface_index >= -1, -EINVAL); + assert_return(interface_index > 0, -EINVAL); assert_return(IN_SET(ll->state, IPV4LL_STATE_INIT, IPV4LL_STATE_STOPPED), -EBUSY); @@ -469,10 +469,13 @@ int sd_ipv4ll_get_address(sd_ipv4ll *ll, struct in_addr *address){ } int sd_ipv4ll_set_address_seed (sd_ipv4ll *ll, uint8_t seed[8]) { - unsigned int entropy = *seed; + unsigned int entropy; int r; assert_return(ll, -EINVAL); + assert_return(seed, -EINVAL); + + entropy = *seed; free(ll->random_data); free(ll->random_data_state); -- cgit v1.2.3-54-g00ecf