Skip to content

Commit

Permalink
network: check for empty string arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Aug 23, 2022
1 parent bf43cce commit 8e77d44
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions network.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ network_set_config(struct network *net, struct blob_attr *config)
blobmsg_len(net->config.data));

if ((cur = tb[NETWORK_ATTR_TYPE]) == NULL ||
!strlen(blobmsg_get_string(cur)) ||
!strcmp(blobmsg_get_string(cur), "dynamic"))
net->config.type = NETWORK_TYPE_DYNAMIC;
else if (!strcmp(blobmsg_get_string(cur), "file"))
Expand Down Expand Up @@ -510,13 +511,16 @@ network_set_config(struct network *net, struct blob_attr *config)
break;
}

if ((cur = tb[NETWORK_ATTR_INTERFACE]) != NULL)
if ((cur = tb[NETWORK_ATTR_INTERFACE]) != NULL &&
strlen(blobmsg_get_string(cur)) > 0)
net->config.interface = blobmsg_get_string(cur);

if ((cur = tb[NETWORK_ATTR_UPDATE_CMD]) != NULL)
if ((cur = tb[NETWORK_ATTR_UPDATE_CMD]) != NULL &&
strlen(blobmsg_get_string(cur)) > 0)
net->config.update_cmd = blobmsg_get_string(cur);

if ((cur = tb[NETWORK_ATTR_DOMAIN]) != NULL)
if ((cur = tb[NETWORK_ATTR_DOMAIN]) != NULL &&
strlen(blobmsg_get_string(cur)) > 0)
net->config.domain = blobmsg_get_string(cur);

if ((cur = tb[NETWORK_ATTR_TUNNELS]) != NULL)
Expand Down

0 comments on commit 8e77d44

Please sign in to comment.