[systemd-devel] [PATCH] libnetworkd: only allow positive ifindex

Umut Tezduyar Lindskog umut at tezduyar.com
Sat Apr 12 04:19:48 PDT 2014


Patch doesn't apply anymore after reference counting changes. I will
re-send it along with ipv4ll tests which is coming up right away.

On Thu, Apr 10, 2014 at 2:35 PM, Umut Tezduyar Lindskog
<umut.tezduyar at axis.com> wrote:
> From: Umut Tezduyar Lindskog <umuttl at axis.com>
>
> ---
>  src/libsystemd-network/sd-dhcp-client.c   |    2 +-
>  src/libsystemd-network/sd-ipv4ll.c        |    2 +-
>  src/libsystemd-network/test-dhcp-client.c |    4 +++-
>  3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
> index da41c47..70d1259 100644
> --- a/src/libsystemd-network/sd-dhcp-client.c
> +++ b/src/libsystemd-network/sd-dhcp-client.c
> @@ -135,7 +135,7 @@ int sd_dhcp_client_set_request_address(sd_dhcp_client *client,
>  int sd_dhcp_client_set_index(sd_dhcp_client *client, int interface_index) {
>          assert_return(client, -EINVAL);
>          assert_return(client->state == DHCP_STATE_INIT, -EBUSY);
> -        assert_return(interface_index >= -1, -EINVAL);
> +        assert_return(interface_index > 0, -EINVAL);
>
>          client->index = interface_index;
>
> diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
> index 81fe85b..393a213 100644
> --- a/src/libsystemd-network/sd-ipv4ll.c
> +++ b/src/libsystemd-network/sd-ipv4ll.c
> @@ -368,7 +368,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(ll->state == IPV4LL_STATE_INIT, -EBUSY);
>
>          ll->index = interface_index;
> diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
> index a208b0d..3ba56b1 100644
> --- a/src/libsystemd-network/test-dhcp-client.c
> +++ b/src/libsystemd-network/test-dhcp-client.c
> @@ -77,7 +77,9 @@ static void test_request_basic(sd_event *e)
>
>          assert_se(sd_dhcp_client_set_index(client, 15) == 0);
>          assert_se(sd_dhcp_client_set_index(client, -42) == -EINVAL);
> -        assert_se(sd_dhcp_client_set_index(client, -1) == 0);
> +        assert_se(sd_dhcp_client_set_index(client, -1) == -EINVAL);
> +        assert_se(sd_dhcp_client_set_index(client, 0) == -EINVAL);
> +        assert_se(sd_dhcp_client_set_index(client, 1) == 0);
>
>          assert_se(sd_dhcp_client_set_request_option(client,
>                                          DHCP_OPTION_SUBNET_MASK) == -EEXIST);
> --
> 1.7.10.4
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list