--- openssh-2.5.1p1-orig/openbsd-compat/bindresvport.c Wed Jan 31 21:52:03 2001 +++ openssh-2.5.1p1/openbsd-compat/bindresvport.c Mon Feb 19 17:17:30 2001 @@ -93,6 +93,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; @@ -116,6 +129,7 @@ if (port > ENDPORT) port = STARTPORT; } +#endif return (error); }