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) |
- 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 @@ | |||
5 | <andre.lucas@dial.pipex.com> | 5 | <andre.lucas@dial.pipex.com> |
6 | - Make IPv4 use the default in RPM packages | 6 | - Make IPv4 use the default in RPM packages |
7 | - Irix uses preformatted manpages | 7 | - Irix uses preformatted manpages |
8 | - Missing htons() in bsd-bindresvport.c, fix from Holger Trapp | ||
9 | <Holger.Trapp@Informatik.TU-Chemnitz.DE> | ||
8 | 10 | ||
9 | 20000120 | 11 | 20000120 |
10 | - Don't use getaddrinfo on AIX | 12 | - Don't use getaddrinfo on AIX |
diff --git a/bsd-bindresvport.c b/bsd-bindresvport.c index 04780673b..15bb667da 100644 --- a/bsd-bindresvport.c +++ b/bsd-bindresvport.c | |||
@@ -61,6 +61,7 @@ bindresvport_af(sd, sa, af) | |||
61 | struct sockaddr_in *sin; | 61 | struct sockaddr_in *sin; |
62 | struct sockaddr_in6 *sin6; | 62 | struct sockaddr_in6 *sin6; |
63 | u_int16_t *portp; | 63 | u_int16_t *portp; |
64 | u_int16_t port; | ||
64 | int salen; | 65 | int salen; |
65 | int i; | 66 | int i; |
66 | 67 | ||
@@ -83,10 +84,13 @@ bindresvport_af(sd, sa, af) | |||
83 | } | 84 | } |
84 | sa->sa_family = af; | 85 | sa->sa_family = af; |
85 | 86 | ||
86 | if (*portp == 0) | 87 | port = ntohs(*portp); |
87 | *portp = (u_int16_t)(arc4random() % NPORTS) + STARTPORT; | 88 | if (port == 0) |
89 | port = (arc4random() % NPORTS) + STARTPORT; | ||
88 | 90 | ||
89 | for(i = 0; i < NPORTS; i++) { | 91 | for(i = 0; i < NPORTS; i++) { |
92 | *portp = htons(port); | ||
93 | |||
90 | error = bind(sd, sa, salen); | 94 | error = bind(sd, sa, salen); |
91 | 95 | ||
92 | /* Terminate on success */ | 96 | /* Terminate on success */ |
@@ -97,7 +101,9 @@ bindresvport_af(sd, sa, af) | |||
97 | if ((error < 0) && !((errno == EADDRINUSE) || (errno == EINVAL))) | 101 | if ((error < 0) && !((errno == EADDRINUSE) || (errno == EINVAL))) |
98 | break; | 102 | break; |
99 | 103 | ||
100 | *portp = (i % NPORTS) + STARTPORT; | 104 | port++; |
105 | if (port > ENDPORT) | ||
106 | port = STARTPORT; | ||
101 | } | 107 | } |
102 | 108 | ||
103 | return (error); | 109 | return (error); |