diff options
author | Damien Miller <djm@mindrot.org> | 2000-01-22 18:17:42 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-01-22 18:17:42 +1100 |
commit | 8dbbe6e546020e880cc01b5c6eb68484df766369 (patch) | |
tree | e0e96ab205f57886f90099b1e67c0a7bb845e326 | |
parent | 0727893340ca559c6fda3a982992f8f75e9ebbea (diff) | |
download | openssh-git-8dbbe6e546020e880cc01b5c6eb68484df766369.tar.gz |
- Missing htons() in bsd-bindresvport.c, fix from Holger Trapp
<Holger.Trapp@Informatik.TU-Chemnitz.DE>
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | bsd-bindresvport.c | 12 |
2 files changed, 11 insertions, 3 deletions
@@ -5,6 +5,8 @@ <andre.lucas@dial.pipex.com> - Make IPv4 use the default in RPM packages - Irix uses preformatted manpages + - Missing htons() in bsd-bindresvport.c, fix from Holger Trapp + <Holger.Trapp@Informatik.TU-Chemnitz.DE> 20000120 - Don't use getaddrinfo on AIX diff --git a/bsd-bindresvport.c b/bsd-bindresvport.c index 04780673..15bb667d 100644 --- a/bsd-bindresvport.c +++ b/bsd-bindresvport.c @@ -61,6 +61,7 @@ bindresvport_af(sd, sa, af) struct sockaddr_in *sin; struct sockaddr_in6 *sin6; u_int16_t *portp; + u_int16_t port; int salen; int i; @@ -83,10 +84,13 @@ bindresvport_af(sd, sa, af) } sa->sa_family = af; - if (*portp == 0) - *portp = (u_int16_t)(arc4random() % NPORTS) + STARTPORT; + port = ntohs(*portp); + if (port == 0) + port = (arc4random() % NPORTS) + STARTPORT; for(i = 0; i < NPORTS; i++) { + *portp = htons(port); + error = bind(sd, sa, salen); /* Terminate on success */ @@ -97,7 +101,9 @@ bindresvport_af(sd, sa, af) if ((error < 0) && !((errno == EADDRINUSE) || (errno == EINVAL))) break; - *portp = (i % NPORTS) + STARTPORT; + port++; + if (port > ENDPORT) + port = STARTPORT; } return (error); |