aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-02-27 19:38:19 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-02-27 19:38:19 +0100
commit99069330a104e6d360635174be5f5ed054c418b8 (patch)
treef800b70a7b8989db14f5964b65534181d4a1a309
parentca228fb16dddc3c959adad97a930612a6b5256db (diff)
downloadbusybox-w32-99069330a104e6d360635174be5f5ed054c418b8.tar.gz
busybox-w32-99069330a104e6d360635174be5f5ed054c418b8.tar.bz2
busybox-w32-99069330a104e6d360635174be5f5ed054c418b8.zip
*: gethostname-related fixes
function old new delta hostname_main 218 231 +13 nfsmount 3541 3474 -67 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/xconnect.c22
-rw-r--r--networking/hostname.c10
-rw-r--r--util-linux/mount.c16
3 files changed, 13 insertions, 35 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 8a1e1c1b2..97751eb27 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -96,28 +96,6 @@ unsigned FAST_FUNC bb_lookup_port(const char *port, const char *protocol, unsign
96} 96}
97 97
98 98
99/* "Old" networking API - only IPv4 */
100
101/*
102void FAST_FUNC bb_lookup_host(struct sockaddr_in *s_in, const char *host)
103{
104 struct hostent *he;
105
106 memset(s_in, 0, sizeof(struct sockaddr_in));
107 s_in->sin_family = AF_INET;
108 he = xgethostbyname(host);
109 memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length);
110}
111
112
113int FAST_FUNC xconnect_tcp_v4(struct sockaddr_in *s_addr)
114{
115 int s = xsocket(AF_INET, SOCK_STREAM, 0);
116 xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr));
117 return s;
118}
119*/
120
121/* "New" networking API */ 99/* "New" networking API */
122 100
123 101
diff --git a/networking/hostname.c b/networking/hostname.c
index 579eff795..121ad40bb 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -132,10 +132,14 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
132 if (*p) 132 if (*p)
133 puts(p + 1); 133 puts(p + 1);
134 } else /*if (opts & OPT_i)*/ { 134 } else /*if (opts & OPT_i)*/ {
135 while (hp->h_addr_list[0]) { 135 if (hp->h_length == sizeof(struct in_addr)) {
136 printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++))); 136 struct in_addr **h_addr_list = (struct in_addr **)hp->h_addr_list;
137 while (*h_addr_list) {
138 printf("%s ", inet_ntoa(**h_addr_list));
139 h_addr_list++;
140 }
141 bb_putchar('\n');
137 } 142 }
138 bb_putchar('\n');
139 } 143 }
140 } else if (opts & OPT_F) { 144 } else if (opts & OPT_F) {
141 /* Set the hostname */ 145 /* Set the hostname */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 4392363ba..620b14667 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -1043,12 +1043,10 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1043 bb_herror_msg("%s", hostname); 1043 bb_herror_msg("%s", hostname);
1044 goto fail; 1044 goto fail;
1045 } 1045 }
1046 if ((size_t)hp->h_length > sizeof(struct in_addr)) { 1046 if (hp->h_length != (int)sizeof(struct in_addr)) {
1047 bb_error_msg("got bad hp->h_length"); 1047 bb_error_msg_and_die("only IPv4 is supported");
1048 hp->h_length = sizeof(struct in_addr);
1049 } 1048 }
1050 memcpy(&server_addr.sin_addr, 1049 memcpy(&server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
1051 hp->h_addr, hp->h_length);
1052 } 1050 }
1053 1051
1054 memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr)); 1052 memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
@@ -1331,13 +1329,11 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1331 bb_herror_msg("%s", mounthost); 1329 bb_herror_msg("%s", mounthost);
1332 goto fail; 1330 goto fail;
1333 } 1331 }
1334 if ((size_t)hp->h_length > sizeof(struct in_addr)) { 1332 if (hp->h_length != (int)sizeof(struct in_addr)) {
1335 bb_error_msg("got bad hp->h_length"); 1333 bb_error_msg_and_die("only IPv4 is supported");
1336 hp->h_length = sizeof(struct in_addr);
1337 } 1334 }
1338 mount_server_addr.sin_family = AF_INET; 1335 mount_server_addr.sin_family = AF_INET;
1339 memcpy(&mount_server_addr.sin_addr, 1336 memcpy(&mount_server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
1340 hp->h_addr, hp->h_length);
1341 } 1337 }
1342 } 1338 }
1343 1339