- 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.
This commit is contained in:
parent
d378c3149c
commit
efd4983eb1
2 changed files with 91 additions and 3 deletions
|
@ -6,7 +6,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "inet_common.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -58,7 +57,7 @@ int xconnect(const char *host, const char *port)
|
|||
struct sockaddr_in s_addr;
|
||||
int s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
struct servent *tserv;
|
||||
int port_nr=atoi(port);
|
||||
int port_nr=htons(atoi(port));
|
||||
struct hostent * he;
|
||||
|
||||
if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL)
|
||||
|
@ -66,7 +65,7 @@ int xconnect(const char *host, const char *port)
|
|||
|
||||
memset(&s_addr, 0, sizeof(struct sockaddr_in));
|
||||
s_addr.sin_family = AF_INET;
|
||||
s_addr.sin_port = htons(port_nr);
|
||||
s_addr.sin_port = port_nr;
|
||||
|
||||
he = xgethostbyname(host);
|
||||
memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue