aboutsummaryrefslogtreecommitdiff
path: root/libbb/xconnect.c
diff options
context:
space:
mode:
authorRobert Griebl <griebl@gmx.de>2002-07-19 20:27:11 +0000
committerRobert Griebl <griebl@gmx.de>2002-07-19 20:27:11 +0000
commitefd4983eb1e6a196bc9d20b0b8840b79cb0f308c (patch)
tree10aa37e6cf260cf08f88ec812a46fc6ea7444c69 /libbb/xconnect.c
parentd378c3149c6c24e7788f04a6d20ba360f3ea407e (diff)
downloadbusybox-w32-efd4983eb1e6a196bc9d20b0b8840b79cb0f308c.tar.gz
busybox-w32-efd4983eb1e6a196bc9d20b0b8840b79cb0f308c.tar.bz2
busybox-w32-efd4983eb1e6a196bc9d20b0b8840b79cb0f308c.zip
- Forgot to cvs add bb_asprintf.c (from vodz' patch #50)
- Applied Joel Coltoff's xconnect patch: On both my host system and with mipsel-linux for my embedded systems the function getservbyname() gives the port number already in host order. In fact, this is how it was used by rdate in version 0.60.3. The snapshot I have of the development tree from July 12, 2002 takes the port number and stuffs it into htons() before it uses it. This causes bugs in rdate, telnet and wget. This patch fixes that.
Diffstat (limited to 'libbb/xconnect.c')
-rw-r--r--libbb/xconnect.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 9e771495d..f3a1b4462 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -6,7 +6,6 @@
6 * 6 *
7 */ 7 */
8 8
9#include "inet_common.h"
10#include <unistd.h> 9#include <unistd.h>
11#include <string.h> 10#include <string.h>
12#include <stdlib.h> 11#include <stdlib.h>
@@ -58,7 +57,7 @@ int xconnect(const char *host, const char *port)
58 struct sockaddr_in s_addr; 57 struct sockaddr_in s_addr;
59 int s = socket(AF_INET, SOCK_STREAM, 0); 58 int s = socket(AF_INET, SOCK_STREAM, 0);
60 struct servent *tserv; 59 struct servent *tserv;
61 int port_nr=atoi(port); 60 int port_nr=htons(atoi(port));
62 struct hostent * he; 61 struct hostent * he;
63 62
64 if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL) 63 if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL)
@@ -66,7 +65,7 @@ int xconnect(const char *host, const char *port)
66 65
67 memset(&s_addr, 0, sizeof(struct sockaddr_in)); 66 memset(&s_addr, 0, sizeof(struct sockaddr_in));
68 s_addr.sin_family = AF_INET; 67 s_addr.sin_family = AF_INET;
69 s_addr.sin_port = htons(port_nr); 68 s_addr.sin_port = port_nr;
70 69
71 he = xgethostbyname(host); 70 he = xgethostbyname(host);
72 memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr); 71 memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr);