summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2013-06-02 09:08:12 -0700
committerDaniil Baturin <daniil@baturin.org>2013-06-02 09:08:12 -0700
commitd8803eecc67e6eba03f6f0e4f15c523b06f67731 (patch)
tree2d2ba28d84e8b057cd326b8d8d810d86dbb3dc46
parent83cf00e0117c4b41001a56f93cf4beae720cc6a0 (diff)
downloadipaddrcheck-d8803eecc67e6eba03f6f0e4f15c523b06f67731.tar.gz
ipaddrcheck-d8803eecc67e6eba03f6f0e4f15c523b06f67731.zip
Do not proceed with further validation if address string is not well formed.
-rw-r--r--src/ipaddrcheck.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ipaddrcheck.c b/src/ipaddrcheck.c
index cc0a26b..26d0dcc 100644
--- a/src/ipaddrcheck.c
+++ b/src/ipaddrcheck.c
@@ -209,12 +209,16 @@ int main(int argc, char* argv[])
address = cidr_from_str(address_str);
int result = RESULT_SUCCESS;
- /* Check if the address is valid at all,
+ /* Check if the address is valid and well-formatted at all,
if not there is no point in going further */
- if( is_valid_address(address) != RESULT_SUCCESS )
+ if( !( (is_valid_address(address) == RESULT_SUCCESS) &&
+ ((is_any_cidr(address_str) == RESULT_SUCCESS) || (is_any_single(address_str) == RESULT_SUCCESS)) ) )
{
+ printf("cond: %d\n", (is_any_cidr(address_str) != RESULT_SUCCESS) || (is_any_single(address_str) != RESULT_SUCCESS));
+ printf("valid: %d\n", (is_valid_address(address) != RESULT_SUCCESS));
return(EXIT_FAILURE);
}
+ /* no else needed, the rest is one big else */
printf("action_count: %d\n", action_count);
while( (action_count >= 0) && (result == RESULT_SUCCESS) )