diff options
| author | Shilpa Gopal <c_shutta@quicinc.com> | 2009-08-01 16:05:30 -0700 |
|---|---|---|
| committer | Shilpa Gopal <c_shutta@quicinc.com> | 2009-08-03 20:13:31 -0700 |
| commit | 172f4ca290926afd242eef207a7f8205c897afe0 (patch) | |
| tree | de624f8e840e8782deb60b574fb3368f7b94f0a1 /libc/netbsd/net/getservent.c | |
| parent | 47f1e2857eed0b542492dfa35580823e0a45f46c (diff) | |
| parent | 6ee8f1b0444c0db94931d2cd64427ded8fba38b0 (diff) | |
| download | bionic-172f4ca290926afd242eef207a7f8205c897afe0.zip bionic-172f4ca290926afd242eef207a7f8205c897afe0.tar.gz bionic-172f4ca290926afd242eef207a7f8205c897afe0.tar.bz2 | |
Merge commit 'quic/korg/donut' into donut
Diffstat (limited to 'libc/netbsd/net/getservent.c')
| -rw-r--r-- | libc/netbsd/net/getservent.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libc/netbsd/net/getservent.c b/libc/netbsd/net/getservent.c index 45207df..65fbd7e 100644 --- a/libc/netbsd/net/getservent.c +++ b/libc/netbsd/net/getservent.c @@ -27,6 +27,7 @@ */ #include <sys/cdefs.h> #include <sys/types.h> +#include <sys/endian.h> #include <netdb.h> #include "servent.h" #include "services.h" @@ -54,6 +55,7 @@ getservent_r( res_static rs ) int namelen; int nn,count; int total = 0; + int port; char* p2; p = rs->servent_ptr; @@ -92,9 +94,12 @@ getservent_r( res_static rs ) memcpy( rs->servent.s_name, p+1, namelen ); rs->servent.s_name[namelen] = 0; p += 1 + namelen; - rs->servent.s_port = ((((unsigned char*)p)[0] << 8) | - ((unsigned char*)p)[1]); + /* s_port must be in network byte order */ + port = ((((unsigned char*)p)[0] << 8) | + ((unsigned char*)p)[1]); + + rs->servent.s_port = htons(port); rs->servent.s_proto = p[2] == 't' ? "tcp" : "udp"; p += 4; /* skip port(2) + proto(1) + aliascount(1) */ |
