Subject: bug#45798: 28.0.50; nsm-check-local-subnet-ipv4 fails with nsm-trust-local-network

From: Robert Pluim <[email-masked]>
Date: Tue, 12 Jan 2021 10:34:36 +0100

"Basil L. Contovounesios" <[email-masked]> writes:

> Oops, sorry!  I must have been looking at the wrong value.  There are
> two cases where nsm-network-same-subnet returns non-nil, and in both
> cases:
>
>   addresses:
>   ([10752 5200 16395 3073 0 0 0 139 0]
>    [10752 5200 16395 3073 0 0 0 113 0]
>    [10752 5200 16395 3073 0 0 0 138 0]
>    [10752 5200 16395 3073 0 0 0 100 0]
>    [74 125 193 139 0] [74 125 193 101 0]
>    [74 125 193 102 0] [74 125 193 138 0]
>    [74 125 193 100 0] [74 125 193 113 0])
>
>   network-interface-list:
>   ((wlp3s0 [65152 0 0 0 38609 2370 19874 38730 0]
>            [65152 0 0 0 65535 65535 65535 65535 0]
>            [65535 65535 65535 65535 0 0 0 0 0])
>    (wlp3s0 [10754 32900 8418 50048 62480 33512 14881 61151 0]
>            [10754 32900 8418 50048 65535 65535 65535 65535 0]
>            [65535 65535 65535 65535 0 0 0 0 0])
>    (lo [0 0 0 0 0 0 0 1 0] [0 0 0 0 0 0 0 1 0]
>        [65535 65535 65535 65535 65535 65535 65535 65535 0])
>    (wlp3s0 [192 168 0 144 0] [192 168 0 255 0] [255 255 255 0 0])
>    (lo [127 0 0 1 0] [127 255 255 255 0] [255 0 0 0 0]))
>
>   info:
>   (lo [0 0 0 0 0 0 0 1 0] [0 0 0 0 0 0 0 1 0]
>       [65535 65535 65535 65535 65535 65535 65535 65535 0])
>
> The only difference is in 'ip':
>
>   1. [10752 5200 16395 3073 0 0 0 139 0]
>   2. [10752 5200 16395 3073 0 0 0 113 0]

What idiot wrote this code? Try this patch:

diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index 3f3e713371..0ce65a35ea 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -239,7 +239,7 @@ nsm-should-check
         (mapc
          (lambda (info)
            (let ((local-ip (nth 1 info))
-                 (mask (nth 2 info)))
+                 (mask (nth 3 info)))
              (when
                  (nsm-network-same-subnet (substring local-ip 0 -1)
                                           (substring mask 0 -1)