diff options
author | Alex Dowad <alexinbeijing@gmail.com> | 2014-04-16 21:46:50 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2014-04-25 10:20:33 +0300 |
commit | e3c03dedff0342a6982de37c491b2c2c724988ae (patch) | |
tree | c36fed69a8acb3f1db9530f3ef78a272e7d95592 /src/blob.c | |
parent | 3aa804965ccc9805df4c8913cd785786ba174081 (diff) | |
download | squark-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.
Diffstat (limited to 'src/blob.c')
-rw-r--r-- | src/blob.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |