[Bug 243164] blacklistd not handling masks correctly

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Jan 8 01:56:07 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=243164

--- Comment #3 from Conrad Meyer <cem at freebsd.org> ---
Ah.  I wonder if this is it?

   459 #define MASK(m)  ((uint32_t)~((1 << (32 - (m))) - 1))
   460
   461 static int
   462 conf_amask_eq(const void *v1, const void *v2, size_t len, int mask)
   463 {
   464         const uint32_t *a1 = v1;
   465         const uint32_t *a2 = v2;
   466         uint32_t m;
   467         int omask = mask;
   468
   469         len >>= 2;
   470         switch (mask) {
   471         case FSTAR:
   472                 if (memcmp(v1, v2, len) == 0)
   473                         return 1;
   474                 goto out;

// Above is definitely wrong, only compares the first 1/4 of the address
// bytes.  Maybe that's what we're seeing?

...
   484         for (size_t i = 0; i < len; i++) {
   485                 if (mask > 32) {
   486                         m = htonl((uint32_t)~0);
   487                         mask -= 32;
   488                 } else if (mask) {
   489                         m = htonl(MASK(mask));
   490                         mask = 0;
   493                 if ((a1[i] & m) != (a2[i] & m))
   494                         goto out;

// This part seems fine for v4, but I'm not sure if it's correct for v6.

   495         }
   496         return 1;
   497 out:
...
   506         return 0;

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list