]> andersk Git - openssh.git/commitdiff
- Missing htons() in bsd-bindresvport.c, fix from Holger Trapp
authordamien <damien>
Sat, 22 Jan 2000 07:17:42 +0000 (07:17 +0000)
committerdamien <damien>
Sat, 22 Jan 2000 07:17:42 +0000 (07:17 +0000)
   <Holger.Trapp@Informatik.TU-Chemnitz.DE>

ChangeLog
bsd-bindresvport.c

index 60654d886a33b6af661c206941b3fc5c63fae60f..cc05e2a1de6aad3d8a628560e4e200f52adac678 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 04780673b7087b38ee77859d939817c5fe414f89..15bb667da50c43f8905f07076f07d13467afe463 100644 (file)
@@ -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);
This page took 0.041622 seconds and 5 git commands to generate.