summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2013-06-01 09:18:59 -0700
committerDaniil Baturin <daniil@baturin.org>2013-06-01 09:18:59 -0700
commit962a4544caaa4b43a5000ccfab55ac5b621dfb5d (patch)
treeabc170ca9c3a1c47ecad1f563c465d871495f6fd
parent9ca7cf169f9308acf9c0dc7252a7fe5993569798 (diff)
downloadipaddrcheck-962a4544caaa4b43a5000ccfab55ac5b621dfb5d.tar.gz
ipaddrcheck-962a4544caaa4b43a5000ccfab55ac5b621dfb5d.zip
Improve IPv4 regular expressions.
-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 e1ac23d..27a33fb 100644
--- a/src/ipaddrcheck_functions.c
+++ b/src/ipaddrcheck_functions.c
@@ -66,7 +66,7 @@ int is_ipv4_cidr(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}/\\d{1,2}$",
+ re = pcre_compile("^((([1-9]\\d{0,2}|0)\\.){3}([1-9]\\d{0,2}|0)(\\/([1-3][0-9]|0)))$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);
@@ -93,7 +93,7 @@ int is_ipv4_single(char* address_str)
const char *error;
int erroffset;
- re = pcre_compile("^\\d{1,3}.\\d{1,3}.\\d{1,3}.\\d{1,3}$",
+ re = pcre_compile("^((([1-9]\\d{0,2}|0)\\.){3}([1-9]\\d{0,2}|0))$",
0, &error, &erroffset, NULL);
rc = pcre_exec(re, NULL, address_str, strlen(address_str), 0, 0, offsets, 1);