Re: [PATCH] Ephemeral port randomization

看板DFBSD_submit作者時間21年前 (2004/04/29 15:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
Jon Parise wrote: > On Wed, Apr 28, 2004 at 06:04:37PM -0400, Skip Ford wrote: > > > /* > > * counting down > > */ > > + if (ipport_randomized) > > + *lastport = first - > > + (arc4random() % (first - last)); > > count = first - last; > > > > do { > > @@ -341,6 +349,9 @@ > > /* > > * counting up > > */ > > + if (ipport_randomized) > > + *lastport = first + > > + (arc4random() % (last - first)); > > count = last - first; > > I don't purport to know this code at all, but, based on these snippets > from the diff, wouldn't it make sense to compute 'count' before the > 'ipport_randomized' test and then use 'count' in the '*lastport' > calculation (instead of repeating the '(last - first)' arithmetic)? Yeah, but that's not how FreeBSD does it. I was planning to send a follow-up patch if they applied the first. I dislike patches that do multiple things so I decided importing FreeBSD's version and optimizing it a bit should be done separately, just like FreeBSD did bringing in OpenBSD's version. -- Skip
文章代碼(AID): #10aAWl00 (DFBSD_submit)
文章代碼(AID): #10aAWl00 (DFBSD_submit)