From 7d7624233adb7889a90b6eb960a4c98e22d1a501 Mon Sep 17 00:00:00 2001 From: Kristof Provost Date: Sun, 25 Oct 2015 13:14:53 +0000 Subject: [PATCH] PF_ANEQ() macro will in most situations returns TRUE comparing two identical IPv4 packets (when it should return FALSE). It happens because PF_ANEQ() doesn't stop if first 32 bits of IPv4 packets are equal and starts to check next 3*32 bits (like for IPv6 packet). Those bits containt some garbage and in result PF_ANEQ() wrongly returns TRUE. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: Check if packet is of AF_INET type and if it is then compare only first 32 bits of data. PR: 204005 Submitted by: MiƂosz Kaniewski --- sys/net/pfvar.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 747da412abdc..62d85897d14a 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -198,10 +198,11 @@ extern struct rwlock pf_rules_lock; (a)->addr32[0] == (b)->addr32[0])) \ #define PF_ANEQ(a, b, c) \ - ((a)->addr32[0] != (b)->addr32[0] || \ + ((c == AF_INET && (a)->addr32[0] != (b)->addr32[0]) || \ + (c == AF_INET6 && (a)->addr32[3] != (b)->addr32[3] && \ (a)->addr32[1] != (b)->addr32[1] || \ (a)->addr32[2] != (b)->addr32[2] || \ - (a)->addr32[3] != (b)->addr32[3]) \ + (a)->addr32[3] != (b)->addr32[3])) \ #define PF_AZERO(a, c) \ ((c == AF_INET && !(a)->addr32[0]) || \