summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-27 03:31:12 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-27 03:31:12 -0700
commit4cab53af779783c811cca6d2705c48b9d081fcda (patch)
tree1fb39cf7eb0f5a8b8c83ff0fec25c097dc2dad07 /libc
parent1ff2ee440bddc84e3216de3c9965943e0b2f020a (diff)
parentcdb68bf8ce26448cfe173d86f1c074e167c3420f (diff)
downloadbionic-4cab53af779783c811cca6d2705c48b9d081fcda.zip
bionic-4cab53af779783c811cca6d2705c48b9d081fcda.tar.gz
bionic-4cab53af779783c811cca6d2705c48b9d081fcda.tar.bz2
am cdb68bf8: Merge change 2470 into donut
Merge commit 'cdb68bf8ce26448cfe173d86f1c074e167c3420f' * commit 'cdb68bf8ce26448cfe173d86f1c074e167c3420f': Fix getservent() so that it returns s_port in network byte order.
Diffstat (limited to 'libc')
-rw-r--r--libc/docs/ISSUES.TXT20
-rw-r--r--libc/netbsd/net/getservent.c9
2 files changed, 27 insertions, 2 deletions
diff --git a/libc/docs/ISSUES.TXT b/libc/docs/ISSUES.TXT
new file mode 100644
index 0000000..b53eb16
--- /dev/null
+++ b/libc/docs/ISSUES.TXT
@@ -0,0 +1,20 @@
+Bionic C Library Issues:
+========================
+
+This document lists important known issues of various releases
+of the Bionic C library. Note that these differ from specific
+implementation choices that are documented in the OVERVIEW.TXT
+document.
+
+Currently known issues:
+-----------------------
+
+- The C library initialization will improperly run static C++
+ constructors located in shared libraries twice.
+
+Android-1.5 issues:
+-------------------
+
+- getservbyname() returned the port number in the s_port field of
+ the 'struct servent' structure in host-byte-order, instead of
+ network-byte-order.
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) */