diff --git a/common/fko_util.c b/common/fko_util.c index 86ab0be3..ca9a58b7 100644 --- a/common/fko_util.c +++ b/common/fko_util.c @@ -125,7 +125,7 @@ int is_valid_ipv4_addr(const char * const ip_str, const int len) { const char *ndx = ip_str; - char tmp_ip_str[MAX_IPV4_STR_LEN + 1]={0}; + char tmp_ip_str[MAX_IPV4_STR_LEN + 1] = {0}; int dot_ctr = 0, char_ctr = 0; int res = 1; #if HAVE_SYS_SOCKET_H @@ -138,10 +138,9 @@ is_valid_ipv4_addr(const char * const ip_str, const int len) if((len > MAX_IPV4_STR_LEN) || (len < MIN_IPV4_STR_LEN)) return 0; - while(char_ctr < len) { - /* If we've hit a null within the given length, then not valid regardless*/ + /* If we've hit a null within the given length, then not valid regardless */ if(*ndx == '\0') return 0; @@ -157,8 +156,6 @@ is_valid_ipv4_addr(const char * const ip_str, const int len) ndx++; } - - if((res == 1) && (dot_ctr != 3)) res = 0; diff --git a/test/tests/basic_operations.pl b/test/tests/basic_operations.pl index c268ed54..5419840f 100644 --- a/test/tests/basic_operations.pl +++ b/test/tests/basic_operations.pl @@ -2045,6 +2045,17 @@ 'positive_output_matches' => [qr/Message.*0.0.0.0/], 'rc_positive_output_matches' => [qr/ALLOW_IP.*0.0.0.0/], }, + { + 'category' => 'basic operations', + 'subcategory' => 'client save rc file', + 'detail' => 'invalid ALLOW_IP', + 'function' => \&client_rc_file, + 'cmdline' => "$client_save_rc_args -n default -s", + 'save_rc_stanza' => [{'name' => 'default', + 'vars' => {'KEY' => 'testtest', 'ALLOW_IP' => '123.999.999.999'}}], + 'exec_err' => $YES, + 'positive_output_matches' => [qr/Parameter\serror/], + }, { 'category' => 'basic operations',