diff mbox series

[01/15] netconfig: Fix address format validation

Message ID 20220616000231.1966008-1-andrew.zaborowski@intel.com (mailing list archive)
State Accepted, archived
Headers show
Series [01/15] netconfig: Fix address format validation | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/netconfig.c: In function ‘netconfig_free_settings’: ../../src/netconfig.c:104:9: warning: implicit declaration of function ‘l_netconfig_reset_config’; did you mean ‘l_netconfig_check_config’? [-Wimplicit-function-declaration] 104 | l_netconfig_reset_config(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_check_config ../../src/netconfig.c: In function ‘netconfig_dns_list_update’: ../../src/netconfig.c:169:17: warning: implicit declaration of function ‘l_netconfig_get_dns_list’; did you mean ‘l_netconfig_get_dhcp_client’? [-Wimplicit-function-declaration] 169 | l_netconfig_get_dns_list(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_get_dhcp_client ../../src/netconfig.c:169:17: warning: initialization of ‘char **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] ../../src/netconfig.c: In function ‘netconfig_domains_update’: ../../src/netconfig.c:178:17: warning: implicit declaration of function ‘l_netconfig_get_domain_names’; did you mean ‘l_netconfig_set_hostname’? [-Wimplicit-function-declaration] 178 | l_netconfig_get_domain_names(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_set_hostname ../../src/netconfig.c:178:17: warning: initialization of ‘char **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] ../../src/netconfig.c: In function ‘netconfig_event_handler’: ../../src/netconfig.c:372:9: error: too few arguments to function ‘l_netconfig_apply_rtnl’ 372 | l_netconfig_apply_rtnl(nc); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./ell/ell.h:45, from ../../src/netconfig.c:40: ../../ell/netconfig.h:88:6: note: declared here 88 | void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, | ^~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [Makefile:2389: src/netconfig.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1574: all] Error 2 make: *** [Makefile:3166: distcheck] Error 1
prestwoj/iwd-ci-incremental_build fail Applying Patch FAIL (patch 0): Committer identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'root@ac1d3a8375d5.(none)')
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/netconfig.c: In function 'netconfig_free_settings': ../../src/netconfig.c:104:9: warning: implicit declaration of function 'l_netconfig_reset_config'; did you mean 'l_netconfig_check_config'? [-Wimplicit-function-declaration] 104 | l_netconfig_reset_config(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_check_config ../../src/netconfig.c: In function 'netconfig_dns_list_update': ../../src/netconfig.c:169:17: warning: implicit declaration of function 'l_netconfig_get_dns_list'; did you mean 'l_netconfig_get_dhcp_client'? [-Wimplicit-function-declaration] 169 | l_netconfig_get_dns_list(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_get_dhcp_client ../../src/netconfig.c:169:17: warning: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion] ../../src/netconfig.c: In function 'netconfig_domains_update': ../../src/netconfig.c:178:17: warning: implicit declaration of function 'l_netconfig_get_domain_names'; did you mean 'l_netconfig_set_hostname'? [-Wimplicit-function-declaration] 178 | l_netconfig_get_domain_names(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_set_hostname ../../src/netconfig.c:178:17: warning: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Wint-conversion] ../../src/netconfig.c: In function 'netconfig_event_handler': ../../src/netconfig.c:372:9: error: too few arguments to function 'l_netconfig_apply_rtnl' 372 | l_netconfig_apply_rtnl(nc); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./ell/ell.h:45, from ../../src/netconfig.c:40: ../../ell/netconfig.h:88:6: note: declared here 88 | void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, | ^~~~~~~~~~~~~~~~~~~~~~ make[2]: *** [Makefile:2390: src/netconfig.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1575: all] Error 2 make: *** [Makefile:3167: distcheck] Error 1
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: src/netconfig.c: In function ‘netconfig_free_settings’: src/netconfig.c:104:9: error: implicit declaration of function ‘l_netconfig_reset_config’; did you mean ‘l_netconfig_check_config’? [-Werror=implicit-function-declaration] 104 | l_netconfig_reset_config(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_check_config src/netconfig.c: In function ‘netconfig_dns_list_update’: src/netconfig.c:169:17: error: implicit declaration of function ‘l_netconfig_get_dns_list’; did you mean ‘l_netconfig_get_dhcp_client’? [-Werror=implicit-function-declaration] 169 | l_netconfig_get_dns_list(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_get_dhcp_client src/netconfig.c:169:17: error: initialization of ‘char **’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function ‘netconfig_domains_update’: src/netconfig.c:178:17: error: implicit declaration of function ‘l_netconfig_get_domain_names’; did you mean ‘l_netconfig_set_hostname’? [-Werror=implicit-function-declaration] 178 | l_netconfig_get_domain_names(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_set_hostname src/netconfig.c:178:17: error: initialization of ‘char **’ from ‘int’ makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function ‘netconfig_event_handler’: src/netconfig.c:372:9: error: too few arguments to function ‘l_netconfig_apply_rtnl’ 372 | l_netconfig_apply_rtnl(nc); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./ell/ell.h:45, from src/netconfig.c:40: ./ell/netconfig.h:88:6: note: declared here 88 | void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, | ^~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2389: src/netconfig.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1574: all] Error 2
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: src/netconfig.c:104:2: error: implicit declaration of function 'l_netconfig_reset_config' is invalid in C99 [-Werror,-Wimplicit-function-declaration] l_netconfig_reset_config(netconfig->nc); ^ src/netconfig.c:104:2: note: did you mean 'l_netconfig_check_config'? ./ell/netconfig.h:71:6: note: 'l_netconfig_check_config' declared here bool l_netconfig_check_config(struct l_netconfig *netconfig); ^ src/netconfig.c:169:3: error: implicit declaration of function 'l_netconfig_get_dns_list' is invalid in C99 [-Werror,-Wimplicit-function-declaration] l_netconfig_get_dns_list(netconfig->nc); ^ src/netconfig.c:169:3: note: did you mean 'l_netconfig_get_dhcp_client'? ./ell/netconfig.h:76:23: note: 'l_netconfig_get_dhcp_client' declared here struct l_dhcp_client *l_netconfig_get_dhcp_client( ^ src/netconfig.c:168:29: error: incompatible integer to pointer conversion initializing 'char **' with an expression of type 'int' [-Werror,-Wint-conversion] _auto_(l_strv_free) char **dns_list = ^ src/netconfig.c:178:3: error: implicit declaration of function 'l_netconfig_get_domain_names' is invalid in C99 [-Werror,-Wimplicit-function-declaration] l_netconfig_get_domain_names(netconfig->nc); ^ src/netconfig.c:178:3: note: did you mean 'l_netconfig_set_hostname'? ./ell/netconfig.h:58:6: note: 'l_netconfig_set_hostname' declared here bool l_netconfig_set_hostname(struct l_netconfig *netconfig, ^ src/netconfig.c:177:29: error: incompatible integer to pointer conversion initializing 'char **' with an expression of type 'int' [-Werror,-Wint-conversion] _auto_(l_strv_free) char **domains = ^ src/netconfig.c:372:27: error: too few arguments to function call, expected 2, have 1 l_netconfig_apply_rtnl(nc); ~~~~~~~~~~~~~~~~~~~~~~ ^ ./ell/netconfig.h:88:6: note: 'l_netconfig_apply_rtnl' declared here void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, ^ src/netconfig.c:612:2: error: implicit declaration of function 'l_netconfig_reset_config' is invalid in C99 [-Werror,-Wimplicit-function-declaration] l_netconfig_reset_config(netconfig->nc); ^ 7 errors generated. make[1]: *** [Makefile:2389: src/netconfig.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1574: all] Error 2
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make FAIL: src/netconfig.c: In function 'netconfig_free_settings': src/netconfig.c:104:9: error: implicit declaration of function 'l_netconfig_reset_config'; did you mean 'l_netconfig_check_config'? [-Werror=implicit-function-declaration] 104 | l_netconfig_reset_config(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_check_config src/netconfig.c: In function 'netconfig_dns_list_update': src/netconfig.c:169:17: error: implicit declaration of function 'l_netconfig_get_dns_list'; did you mean 'l_netconfig_get_dhcp_client'? [-Werror=implicit-function-declaration] 169 | l_netconfig_get_dns_list(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_get_dhcp_client src/netconfig.c:169:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function 'netconfig_domains_update': src/netconfig.c:178:17: error: implicit declaration of function 'l_netconfig_get_domain_names'; did you mean 'l_netconfig_set_hostname'? [-Werror=implicit-function-declaration] 178 | l_netconfig_get_domain_names(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_set_hostname src/netconfig.c:178:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function 'netconfig_event_handler': src/netconfig.c:372:9: error: too few arguments to function 'l_netconfig_apply_rtnl' 372 | l_netconfig_apply_rtnl(nc); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./ell/ell.h:45, from src/netconfig.c:40: ./ell/netconfig.h:88:6: note: declared here 88 | void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, | ^~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2390: src/netconfig.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1575: all] Error 2
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-alpine-ci-incremental_build fail Make FAIL (patch 12): src/netconfig.c: In function 'netconfig_free_settings': src/netconfig.c:104:9: error: implicit declaration of function 'l_netconfig_reset_config'; did you mean 'l_netconfig_check_config'? [-Werror=implicit-function-declaration] 104 | l_netconfig_reset_config(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_check_config src/netconfig.c: In function 'netconfig_dns_list_update': src/netconfig.c:169:17: error: implicit declaration of function 'l_netconfig_get_dns_list'; did you mean 'l_netconfig_get_dhcp_client'? [-Werror=implicit-function-declaration] 169 | l_netconfig_get_dns_list(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_get_dhcp_client src/netconfig.c:169:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function 'netconfig_domains_update': src/netconfig.c:178:17: error: implicit declaration of function 'l_netconfig_get_domain_names'; did you mean 'l_netconfig_set_hostname'? [-Werror=implicit-function-declaration] 178 | l_netconfig_get_domain_names(netconfig->nc); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | l_netconfig_set_hostname src/netconfig.c:178:17: error: initialization of 'char **' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] src/netconfig.c: In function 'netconfig_event_handler': src/netconfig.c:372:9: error: too few arguments to function 'l_netconfig_apply_rtnl' 372 | l_netconfig_apply_rtnl(nc); | ^~~~~~~~~~~~~~~~~~~~~~ In file included from ./ell/ell.h:45, from src/netconfig.c:40: ./ell/netconfig.h:88:6: note: declared here 88 | void l_netconfig_apply_rtnl(struct l_netconfig *netconfig, | ^~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2390: src/netconfig.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1575: all] Error 2

Commit Message

Andrew Zaborowski June 16, 2022, 12:02 a.m. UTC
Drop the wrong negation in the error check.  Check that there are no extra
characters after prefix length suffix.  Reset errno 0 before the strtoul
call, as recommended by the manpage.
---
 src/netconfig.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Denis Kenzior June 17, 2022, 7:04 p.m. UTC | #1
Hi Andrew,

On 6/15/22 19:02, Andrew Zaborowski wrote:
> Drop the wrong negation in the error check.  Check that there are no extra
> characters after prefix length suffix.  Reset errno 0 before the strtoul
> call, as recommended by the manpage.
> ---
>   src/netconfig.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/netconfig.c b/src/netconfig.c
index 2ab03b90..4a70b0ca 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -515,6 +515,7 @@  static struct l_rtnl_address *netconfig_get_static6_address(
 {
 	L_AUTO_FREE_VAR(char *, ip);
 	char *p;
+	char *endp;
 	struct l_rtnl_address *ret;
 	uint32_t prefix_len = 128;
 
@@ -530,8 +531,9 @@  static struct l_rtnl_address *netconfig_get_static6_address(
 	if (*++p == '\0')
 		goto no_prefix_len;
 
-	prefix_len = strtoul(p, NULL, 10);
-	if (!unlikely(errno == EINVAL || errno == ERANGE ||
+	errno = 0;
+	prefix_len = strtoul(p, &endp, 10);
+	if (unlikely(*endp != '\0' || errno ||
 			!prefix_len || prefix_len > 128)) {
 		l_error("netconfig: Invalid prefix '%s' provided in network"
 				" configuration file", p);