Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 0aa96d81d066a9a76d7262dd49172b49 > files > 10

milter-greylist-4.2.6-1502.fc15.src.rpm

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]",