PF: Fix Operating System Fingerprinting
authorJan Lentfer <Jan.Lentfer@web.de>
Sat, 9 Oct 2010 17:40:30 +0000 (19:40 +0200)
committerJan Lentfer <Jan.Lentfer@web.de>
Sat, 9 Oct 2010 17:43:05 +0000 (19:43 +0200)
   Due to some wrongly imported byte-order conversions osfp was
   broken.

   Reported and tested by: Matthias Schmidt (matthias@dragonflybsd.org)

sys/net/pf/pf_osfp.c

index 63802da..8fe7e6d 100644 (file)
@@ -125,7 +125,7 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st
        if ((tcp->th_flags & (TH_SYN|TH_ACK)) != TH_SYN)
                return (NULL);
        if (ip) {
-               if ((ip->ip_off & htons(IP_OFFMASK)) != 0)
+               if ((ip->ip_off & IP_OFFMASK) != 0)
                        return (NULL);
        }
 
@@ -136,9 +136,9 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st
                struct sockaddr_in sin;
 #endif
 
-               fp.fp_psize = ntohs(ip->ip_len);
+               fp.fp_psize = ip->ip_len;
                fp.fp_ttl = ip->ip_ttl;
-               if (ip->ip_off & htons(IP_DF))
+               if (ip->ip_off & IP_DF)
                        fp.fp_flags |= PF_OSFP_DF;
 #ifdef _KERNEL
                strlcpy(srcname, inet_ntoa(ip->ip_src), sizeof(srcname));
@@ -206,13 +206,12 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st
                                            sizeof(fp.fp_mss));
                                fp.fp_tcpopts = (fp.fp_tcpopts <<
                                    PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_MSS;
-                               NTOHS(fp.fp_mss);
+                               fp.fp_mss = ntohs(fp.fp_mss);
                                break;
                        case TCPOPT_WINDOW:
                                if (optlen >= TCPOLEN_WINDOW)
                                        memcpy(&fp.fp_wscale, &optp[2],
                                            sizeof(fp.fp_wscale));
-                               NTOHS(fp.fp_wscale);
                                fp.fp_tcpopts = (fp.fp_tcpopts <<
                                    PF_OSFP_TCPOPT_BITS) |
                                    PF_OSFP_TCPOPT_WSCALE;