[test suite] add invalid ALLOW_IP test

This commit is contained in:
Michael Rash 2018-08-11 08:23:41 -07:00
parent 40d554103c
commit 69291b91fa
2 changed files with 13 additions and 5 deletions

View File

@ -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;

View File

@ -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',