summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-10-15 07:53:19 +0200
committerGitHub <noreply@github.com>2018-10-15 07:53:19 +0200
commitb6a22e51809ffaf6fe97f818051df34d9859a5ad (patch)
tree221e63bdb1770477d84a182b83280da36a8150b6
parent89bc3caa89c28d819af2ddde6df9570c01c96e94 (diff)
parent418d0113a78ba57f525553b9b150d6adeaf38c0a (diff)
downloadipaddrcheck-b6a22e51809ffaf6fe97f818051df34d9859a5ad.tar.gz
ipaddrcheck-b6a22e51809ffaf6fe97f818051df34d9859a5ad.zip
Merge pull request #1 from EwaldvanGeffen/patch-1
T816 ipaddrcheck / libcidr but on IPv6 network validation
-rw-r--r--src/ipaddrcheck_functions.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ipaddrcheck_functions.c b/src/ipaddrcheck_functions.c
index 82d01f9..2ce7e52 100644
--- a/src/ipaddrcheck_functions.c
+++ b/src/ipaddrcheck_functions.c
@@ -101,7 +101,7 @@ int is_ipv6_cidr(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^((([0-9a-fA-F\\:])+)(\\/\\d{1,3}))$",
+ re = pcre_compile("^(((?:(?:(?:[A-F0-9]{1,4}:){6}|(?=(?:[A-F0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}$)(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)|::(?:[A-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}$)(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7}))(\\/\\d{1,3}))$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);
@@ -128,7 +128,7 @@ int is_ipv6_single(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^(([0-9a-fA-F\\:])+)$",
+ re = pcre_compile("^(?:(?:(?:[A-F0-9]{1,4}:){6}|(?=(?:[A-F0-9]{0,4}:){0,6}(?:[0-9]{1,3}\.){3}[0-9]{1,3}$)(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)|::(?:[A-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}$)(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7})$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);