Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src



On Fri, Jul 25, 2008 at 09:49:11AM +0200, Wolfgang Solfrank wrote:
> Hi,
> 
> Darren Reed wrote:
> > cvs rdiff -r1.36 -r1.37 src/sys/dist/ipf/netinet/ip_nat.c
> 
> Hmm, this has an interesting number of bugs in just one statement ;-)
> 
>                                 port = ipf_random() % (ntohs(np->in_pmax) -
>                                                        ntohs(np->in_pmin));
> 
> I think what you meant here is something like:
> 
>                                 port = ntohs(ipf_random() % (np->in_pmax - 
>                                 np->in_pmin)
>                                              + np->in_pmin);
> 
> i.e., the placement of ntohs is wrong, plus the offset of the port number 
> is missing.

I suspect you don't want to rely on ntohs() only evaluating its arg once.
so:
                port = ipf_random() % (np->in_pmax - np->in_pmin);
                port = ntohs(port);


        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index