aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Santos <[email protected]>2010-10-05 16:47:24 -0400
committerBjörn Gustavsson <[email protected]>2010-10-06 14:57:42 +0200
commitd9edfa887c75426b3d0cc17710bce47523adf243 (patch)
treec82d17a40d05d14ae262d31172dbc97d65f85800 /lib
parentd8f8eeba477fd8872f1136fc507fa299f013cc46 (diff)
downloadotp-d9edfa887c75426b3d0cc17710bce47523adf243.tar.gz
otp-d9edfa887c75426b3d0cc17710bce47523adf243.tar.bz2
otp-d9edfa887c75426b3d0cc17710bce47523adf243.zip
erl_call: remove get_hostent
get_hostent does not properly handle IPv4 addresses on little endian platforms and fails with hostnames beginning with a number. Remove get_hostent and use ei_gethostbyname directly since gethostbyname supports IPv4 addresses. Reported-By: Julien Barbot
Diffstat (limited to 'lib')
-rw-r--r--lib/erl_interface/src/prog/erl_call.c31
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c
index 448de9aa23..33ff6da7c9 100644
--- a/lib/erl_interface/src/prog/erl_call.c
+++ b/lib/erl_interface/src/prog/erl_call.c
@@ -118,7 +118,6 @@ static void usage_arg(const char *progname, const char *switchname);
static void usage_error(const char *progname, const char *switchname);
static void usage(const char *progname);
static int get_module(char **mbuf, char **mname);
-static struct hostent* get_hostent(char *host);
static int do_connect(ei_cnode *ec, char *nodename, struct call_flags *flags);
static int read_stdin(char **buf);
static void split_apply_string(char *str, char **mod,
@@ -367,8 +366,8 @@ int erl_call(int argc, char **argv)
* Expand name to a real name (may be ip-address)
*/
/* FIXME better error string */
- if ((hp = get_hostent(host)) == 0) {
- fprintf(stderr,"erl_call: can't get_hostent(%s)\n", host);
+ if ((hp = ei_gethostbyname(host)) == 0) {
+ fprintf(stderr,"erl_call: can't ei_gethostbyname(%s)\n", host);
exit(1);
}
/* If shortnames, cut off the name at first '.' */
@@ -604,32 +603,6 @@ int erl_call(int argc, char **argv)
*
***************************************************************************/
-/*
- * Get host entry (by address or name)
- */
-/* FIXME: will fail on names like '2fun4you'. */
-static struct hostent* get_hostent(char *host)
-{
- if (isdigit((int)*host)) {
- struct in_addr ip_addr;
- int b1, b2, b3, b4;
- long addr;
-
- /* FIXME: Use inet_aton() (or inet_pton() and get v6 for free). */
- if (sscanf(host, "%d.%d.%d.%d", &b1, &b2, &b3, &b4) != 4) {
- return NULL;
- }
- addr = inet_addr(host);
- ip_addr.s_addr = htonl(addr);
-
- return ei_gethostbyaddr((char *)&ip_addr,sizeof(struct in_addr), AF_INET);
- }
-
- return ei_gethostbyname(host);
-} /* get_hostent */
-
-
-
/*
* This function does only return on success.