summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Dowad <alexinbeijing@gmail.com>2014-04-16 21:46:50 +0200
committerTimo Teräs <timo.teras@iki.fi>2014-04-25 10:20:33 +0300
commite3c03dedff0342a6982de37c491b2c2c724988ae (patch)
treec36fed69a8acb3f1db9530f3ef78a272e7d95592
parent3aa804965ccc9805df4c8913cd785786ba174081 (diff)
downloadsquark-e3c03dedff0342a6982de37c491b2c2c724988ae.tar.bz2
squark-e3c03dedff0342a6982de37c491b2c2c724988ae.tar.xz
squark-filter: reject lines with invalid IP addresses
Input lines which contain client IPs with octets > 255 will not be processed.
-rw-r--r--src/blob.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/blob.c b/src/blob.c
index 4ddc156..3abd0c5 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -192,10 +192,14 @@ void blob_percent_decode(blob_t *blob)
int blob_pull_inet_addr(blob_t *b, struct in_addr *saddr)
{
unsigned long ip = 0;
+ unsigned int octet;
int i;
for (i = 0; i < 3; i++) {
- ip += blob_pull_uint(b, 10);
+ octet = blob_pull_uint(b, 10);
+ if (octet > 255)
+ return 0;
+ ip += octet;
ip <<= 8;
if (!blob_pull_matching(b, BLOB_STR(".")))
return 0;