--- openssh-2.3.0p1-orig/bsd-bindresvport.c Mon Jul 24 23:04:37 2000 +++ openssh-2.3.0p1/bsd-bindresvport.c Sat Feb 17 14:12:48 2001 @@ -85,6 +85,19 @@ sa->sa_family = af; port = ntohs(*portp); + +#if 1 + for(port=ENDPORT;port>0;port--) + { + if (*portp) { + if (!(error = bind(sd, sa, salen))) return error; + if ((error < 0) && !((errno == EADDRINUSE) || (errno == EINVAL))) return error; + } + *portp=htons(port); + } + +#else + if (port == 0) port = (arc4random() % NPORTS) + STARTPORT; @@ -105,6 +118,7 @@ if (port > ENDPORT) port = STARTPORT; } +#endif return (error); }