cl-rw

Layered streams for Common Lisp
git clone https://logand.com/git/cl-rw.git/
Log | Files | Refs

commit ebd48f28bc88c5912f2ed6e889bf5bc5d2829b82
parent 5432d0eadf88294c7b8ef3fff665c82cbc47fe3d
Author: Tomas Hlavaty <tom@logand.com>
Date:   Mon, 29 Dec 2014 12:34:30 +0100

stricter ip address parsing

Diffstat:
Mdns.lisp | 8++++----
Msocket.lisp | 10++++++++--
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/dns.lisp b/dns.lisp @@ -413,13 +413,13 @@ ,(rw.socket:make-ipv4-address "208.67.220.220") ;; resolver2.opendns.com ,(rw.socket:make-ipv4-address "208.67.222.220") ,(rw.socket:make-ipv4-address "208.67.220.222") - ,(rw.socket:make-ipv4-address "2620:0:ccc::2") ;;;;; - ,(rw.socket:make-ipv4-address "2620:0:ccd::2")) ;;;;; + ,(rw.socket:make-ipv6-address "2620:0:ccc::2") + ,(rw.socket:make-ipv6-address "2620:0:ccd::2")) (:google ,(rw.socket:make-ipv4-address "8.8.8.8") ,(rw.socket:make-ipv4-address "8.8.4.4") - ,(rw.socket:make-ipv4-address "2001:4860:4860::8888") ;;;; - ,(rw.socket:make-ipv4-address "2001:4860:4860::8844")) + ,(rw.socket:make-ipv6-address "2001:4860:4860::8888") + ,(rw.socket:make-ipv6-address "2001:4860:4860::8844")) (:comodo ,(rw.socket:make-ipv4-address "8.26.56.26") ,(rw.socket:make-ipv4-address "8.20.247.20")) diff --git a/socket.lisp b/socket.lisp @@ -79,7 +79,9 @@ (t a)))))) (defun parse-ipv4-address (x) - (next-ipv4-address (rw:peek-reader (rw:reader x)))) + (let ((r (rw:peek-reader (rw:reader x)))) + (prog1 (next-ipv4-address r) + (assert (not (rw:peek r)))))) ;;(parse-ipv4-address "172.31.53.254") ;;(parse-ipv4-address "172.2045438") @@ -94,6 +96,8 @@ ;;(parse-ipv4-address "3221226219") ;;(parse-ipv4-address "030000001353") ;;(parse-ipv4-address "127.1") +;;(parse-ipv4-address "127.0.1") +;;(parse-ipv4-address "127.0.0.1") (defun ipv4-integer-to-dotted (x) (format nil "~d.~d.~d.~d" @@ -170,7 +174,9 @@ (logior x (chain hn))))))))))) (defun parse-ipv6-address (x) - (next-ipv6-address (rw:peek-reader (rw:reader x)))) + (let ((r (rw:peek-reader (rw:reader x)))) + (prog1 (next-ipv6-address r) + (assert (not (rw:peek r)))))) ;;(parse-ipv6-address "::") ;;(parse-ipv6-address "::1")