[milter-greylist/f15/master] fixed byte order of src port in p0f check

ensc ensc at fedoraproject.org
Sat Apr 23 11:07:59 UTC 2011


commit 137ccea1007fdf7e9dc53e809ac61728f903012a
Author: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
Date:   Tue Mar 1 18:32:58 2011 +0100

    fixed byte order of src port in p0f check

 milter-greylist.spec |    5 +++++
 p0f-srcport.patch    |   25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/milter-greylist.spec b/milter-greylist.spec
index a76a058..a362963 100644
--- a/milter-greylist.spec
+++ b/milter-greylist.spec
@@ -41,6 +41,7 @@ Patch7:		milter-greylist-dkim-reentrant.patch
 Patch8:		cloexec.patch
 # http://tech.groups.yahoo.com/group/milter-greylist/message/5564
 Patch9:		spamd-null.patch
+Patch10:	p0f-srcport.patch
 BuildRoot:	%_tmppath/%name-%version-%release-root
 Requires:		init(%name)
 Provides:		user(%username)  = 7
@@ -147,6 +148,7 @@ This package provides the systemd initscripts for the %name package.
 %apply -n7 -p1
 %apply -n8 -p1
 %apply -n9 -p1
+%apply -n10 -p1
 
 install -p -m0644 %SOURCE1 .
 
@@ -300,6 +302,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Tue Mar  1 2011 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
+- fixed byte order of src port in p0f check
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 4.2.6-1501
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 
diff --git a/p0f-srcport.patch b/p0f-srcport.patch
new file mode 100644
index 0000000..28a5e57
--- /dev/null
+++ b/p0f-srcport.patch
@@ -0,0 +1,25 @@
+Fixed encoding of ports in p0f queries
+
+p0f expects the src_port and dst_port attributes in system byte order
+(while src_ad and dst_ad are encoded in network byte order).
+
+Although src_port encoding worked in existing code, patch makes it
+clear that a 'ntohs(htons(port))' operation is requested instead of
+relying on, that 'htons(htons(port)) == port' holds.
+
+Index: milter-greylist-4.2.6/p0f.c
+===================================================================
+--- milter-greylist-4.2.6.orig/p0f.c
++++ milter-greylist-4.2.6/p0f.c
+@@ -181,9 +181,9 @@ p0f_lookup(priv)
+ 	req.id = tv.tv_usec;
+ 	req.type = QTYPE_FINGERPRINT;
+ 	req.src_ad = SADDR4(&priv->priv_addr)->s_addr;
+-	req.src_port = htons(SA4(&priv->priv_addr)->sin_port);
++	req.src_port = ntohs(SA4(&priv->priv_addr)->sin_port);
+ 	req.dst_ad = inet_addr(daddr);
+-	req.dst_port = htons(atoi(dport));
++	req.dst_port = atoi(dport);
+ 
+ 	if (conf.c_debug)
+ 		 mg_log(LOG_DEBUG, "p0f_lookup: %s[%d] -> %s[%d]",


More information about the scm-commits mailing list