summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2019-11-18 10:57:55 +0100
committerRobert Pluim <rpluim@gmail.com>2019-11-19 13:36:07 +0100
commitcf0a76a43831105d74b54f0e50f77eb60460fbea (patch)
treeae3826dddc319ea19d61ef26fb8e997f2ac5e9e7 /lisp
parent067a42f8dd2ce19de3203605ee8c1c08aa192580 (diff)
downloademacs-cf0a76a43831105d74b54f0e50f77eb60460fbea.tar.gz
emacs-cf0a76a43831105d74b54f0e50f77eb60460fbea.tar.bz2
emacs-cf0a76a43831105d74b54f0e50f77eb60460fbea.zip
Don't error when comparing IPv4 and IPv6 addresses
* lisp/net/nsm.el (nsm-network-same-subnet): Compare lengths of local-ip and ip; different lengths can never match. (nsm-should-check): Chop port off end of address.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/nsm.el26
1 files changed, 15 insertions, 11 deletions
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index c47ef55a6f4..205b7974883 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -204,17 +204,21 @@ LOCAL-IP, MASK, and IP are specified as vectors of integers, and
are expected to have the same length. Works for both IPv4 and
IPv6 addresses."
(let ((matches t)
- (length (length local-ip)))
- (unless (memq length '(4 5 8 9))
+ (ip-length (length ip))
+ (local-length (length local-ip)))
+ (unless (and (memq ip-length '(4 5 8 9))
+ (memq local-length '(4 5 8 9)))
(error "Unexpected length of IP address %S" local-ip))
- (dotimes (i length)
- (setq matches (and matches
- (=
- (logand (aref local-ip i)
- (aref mask i))
- (logand (aref ip i)
- (aref mask i))))))
- matches))
+ (if (/= ip-length local-length)
+ nil
+ (dotimes (i local-length)
+ (setq matches (and matches
+ (=
+ (logand (aref local-ip i)
+ (aref mask i))
+ (logand (aref ip i)
+ (aref mask i))))))
+ matches)))
(defun nsm-should-check (host)
"Determine whether NSM should check for TLS problems for HOST.
@@ -238,7 +242,7 @@ otherwise."
(when
(nsm-network-same-subnet (substring (car info) 0 -1)
(substring (car (cddr info)) 0 -1)
- address)
+ (substring address 0 -1))
(setq off-net nil))))
network-interface-list))
addresses))