Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 703212
Collapse All | Expand All

(-)a/CHANGES (+4 lines)
Lines 12-17 corrections: Link Here
12
	cross compiling.
12
	cross compiling.
13
	Thanks to Max Freisinger from Gentoo for seinding a patch.
13
	Thanks to Max Freisinger from Gentoo for seinding a patch.
14
14
15
	Socat still depended on obsolete gethostbyname() function, thus
16
	compiling with MUSL libc failed.
17
	Problem reported by Kennedy33.
18
15
testing:
19
testing:
16
	test.sh: Show a warning when phase-1 (insecure phase) of a security
20
	test.sh: Show a warning when phase-1 (insecure phase) of a security
17
	test fails
21
	test fails
(-)a/config.h.in (+3 lines)
Lines 99-104 Link Here
99
/* Define if you have the nanosleep function.  */
99
/* Define if you have the nanosleep function.  */
100
#undef HAVE_NANOSLEEP
100
#undef HAVE_NANOSLEEP
101
101
102
/* Define if you have the gethostbyname function.  */
103
#undef HAVE_GETHOSTBYNAME
104
102
/* Define if you have the getaddrinfo function.  */
105
/* Define if you have the getaddrinfo function.  */
103
#undef HAVE_GETADDRINFO
106
#undef HAVE_GETADDRINFO
104
107
(-)a/configure.in (-1 / +1 lines)
Lines 740-746 AC_FUNC_MEMCMP Link Here
740
AC_TYPE_SIGNAL
740
AC_TYPE_SIGNAL
741
AC_FUNC_STRFTIME
741
AC_FUNC_STRFTIME
742
AC_CHECK_FUNCS(putenv select poll socket strtod strtol)
742
AC_CHECK_FUNCS(putenv select poll socket strtod strtol)
743
AC_CHECK_FUNCS(strtoul uname getpgid getsid getaddrinfo)
743
AC_CHECK_FUNCS(strtoul uname getpgid getsid gethostbyname getaddrinfo)
744
AC_CHECK_FUNCS(setgroups inet_aton)
744
AC_CHECK_FUNCS(setgroups inet_aton)
745
AC_CHECK_FUNCS()
745
AC_CHECK_FUNCS()
746
746
(-)a/sycls.c (-2 / +2 lines)
Lines 1364-1370 int Pause(void) { Link Here
1364
   return retval;
1364
   return retval;
1365
}
1365
}
1366
1366
1367
#if WITH_IP4 || WITH_IP6
1367
#if ( _WITH_IP4 || _WITH_IP6 ) && HAVE_GETHOSTBYNAME
1368
struct hostent *Gethostbyname(const char *name) {
1368
struct hostent *Gethostbyname(const char *name) {
1369
   struct hostent *hent;
1369
   struct hostent *hent;
1370
   Debug1("gethostbyname(\"%s\")", name);
1370
   Debug1("gethostbyname(\"%s\")", name);
Lines 1380-1386 struct hostent *Gethostbyname(const char *name) { Link Here
1380
   }
1380
   }
1381
   return hent;
1381
   return hent;
1382
}
1382
}
1383
#endif /* WITH_IP4 || WITH_IP6 */
1383
#endif /* ( _WITH_IP4 || _WITH_IP6 ) && HAVE_GETHOSTBYNAME */
1384
1384
1385
#if (_WITH_IP4 || _WITH_IP6) && HAVE_GETADDRINFO
1385
#if (_WITH_IP4 || _WITH_IP6) && HAVE_GETADDRINFO
1386
int Getaddrinfo(const char *node, const char *service,
1386
int Getaddrinfo(const char *node, const char *service,
(-)a/xio-ip4.c (-17 / +13 lines)
Lines 15-26 Link Here
15
15
16
16
17
int xioparsenetwork_ip4(const char *rangename, struct xiorange *range) {
17
int xioparsenetwork_ip4(const char *rangename, struct xiorange *range) {
18
   struct hostent *maskaddr;
19
   struct in_addr *netaddr_in = &range->netaddr.ip4.sin_addr;
18
   struct in_addr *netaddr_in = &range->netaddr.ip4.sin_addr;
20
   struct in_addr *netmask_in = &range->netmask.ip4.sin_addr;
19
   struct in_addr *netmask_in = &range->netmask.ip4.sin_addr;
21
   char *rangename1;	/* a copy of rangename with writing allowed */
20
   char *rangename1;	/* a copy of rangename with writing allowed */
22
   char *delimpos;	/* absolute address of delimiter */
21
   char *delimpos;	/* absolute address of delimiter */
23
   unsigned int bits;	/* netmask bits */
22
   unsigned int bits;	/* netmask bits */
23
   union sockaddr_union sau;
24
   socklen_t socklen = sizeof(sau);
25
   int rc;
24
26
25
   if ((rangename1 = strdup(rangename)) == NULL) {
27
   if ((rangename1 = strdup(rangename)) == NULL) {
26
      Error1("strdup(\"%s\"): out of memory", rangename);
28
      Error1("strdup(\"%s\"): out of memory", rangename);
Lines 43-73 int xioparsenetwork_ip4(const char *rangename, struct xiorange *range) { Link Here
43
	 netmask_in->s_addr = htonl((0xffffffff << (32-bits)));
45
	 netmask_in->s_addr = htonl((0xffffffff << (32-bits)));
44
      }
46
      }
45
   } else if (delimpos = strchr(rangename1, ':')) {
47
   } else if (delimpos = strchr(rangename1, ':')) {
46
      if ((maskaddr = Gethostbyname(delimpos+1)) == NULL) {
48
      if ((rc = xiogetaddrinfo(delimpos+1, NULL, PF_UNSPEC, 0, 0,
47
	 /* note: cast is req on AIX: */
49
			       &sau, &socklen, 0, 0))
48
	 Error2("gethostbyname(\"%s\"): %s", delimpos+1,
50
	  != STAT_OK) {
49
		h_errno == NETDB_INTERNAL ? strerror(errno) :
51
	 return rc;
50
		(char *)hstrerror(h_errno));
51
	 return STAT_NORETRY;
52
      }
52
      }
53
      netmask_in->s_addr = *(uint32_t *)maskaddr->h_addr_list[0];
53
      netmask_in->s_addr = sau.ip4.sin_addr.s_addr;
54
   } else {
54
   } else {
55
      Error1("xioparsenetwork_ip4(\"%s\",,): missing netmask delimiter", rangename);
55
      Error1("xioparsenetwork_ip4(\"%s\",,): missing netmask delimiter", rangename);
56
      free(rangename1);
56
      free(rangename1);
57
      return STAT_NORETRY;
57
      return STAT_NORETRY;
58
   }
58
   }
59
   {
59
   {
60
      struct hostent *nameaddr;
61
      *delimpos = 0;
60
      *delimpos = 0;
62
      if ((nameaddr = Gethostbyname(rangename1)) == NULL) {
61
      if ((rc = xiogetaddrinfo(rangename1, NULL, PF_UNSPEC, 0, 0,
63
	 /* note: cast is req on AIX: */
62
			       &sau, &socklen, 0, 0))
64
	 Error2("gethostbyname(\"%s\"): %s", rangename1,
63
	  != STAT_OK) {
65
		h_errno == NETDB_INTERNAL ? strerror(errno) :
64
	 return rc;
66
		(char *)hstrerror(h_errno));
67
	    free(rangename1);
68
	 return STAT_NORETRY;
69
      }
65
      }
70
      netaddr_in->s_addr = *(uint32_t *)nameaddr->h_addr_list[0];
66
      netaddr_in->s_addr = sau.ip4.sin_addr.s_addr;
71
   }
67
   }
72
   free(rangename1);
68
   free(rangename1);
73
   return STAT_OK;
69
   return STAT_OK;
(-)a/xio-proxy.c (-13 / +12 lines)
Lines 11-16 Link Here
11
11
12
#include "xioopen.h"
12
#include "xioopen.h"
13
#include "xio-socket.h"
13
#include "xio-socket.h"
14
#include "xio-ip.h"
14
#include "xio-ipapp.h"
15
#include "xio-ipapp.h"
15
#include "xio-ascii.h"	/* for base64 encoding of authentication */
16
#include "xio-ascii.h"	/* for base64 encoding of authentication */
16
17
Lines 231-237 static int xioopen_proxy_connect(int argc, const char *argv[], struct opt *opts, Link Here
231
232
232
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts,
233
int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts,
233
			   const char *targetname, const char *targetport) {
234
			   const char *targetname, const char *targetport) {
234
   struct hostent *host;
235
   union sockaddr_union host;
236
   socklen_t socklen = sizeof(host);
237
   int rc;
235
238
236
   retropt_bool(opts, OPT_IGNORECR, &proxyvars->ignorecr);
239
   retropt_bool(opts, OPT_IGNORECR, &proxyvars->ignorecr);
237
   retropt_bool(opts, OPT_PROXY_RESOLVE, &proxyvars->doresolve);
240
   retropt_bool(opts, OPT_PROXY_RESOLVE, &proxyvars->doresolve);
Lines 241-254 int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts, Link Here
241
      /* currently we only resolve to IPv4 addresses. This is in accordance to
244
      /* currently we only resolve to IPv4 addresses. This is in accordance to
242
	 RFC 2396; however once it becomes clear how IPv6 addresses should be
245
	 RFC 2396; however once it becomes clear how IPv6 addresses should be
243
	 represented in CONNECT commands this code might be extended */
246
	 represented in CONNECT commands this code might be extended */
244
      host = Gethostbyname(targetname);
247
      rc = xiogetaddrinfo(targetname, targetport, PF_UNSPEC,
245
      if (host == NULL) {
248
			  SOCK_STREAM, IPPROTO_TCP,
246
	 int level = E_WARN;
249
			  &host, &socklen, 0, 0);
247
	 /* note: cast is req on AIX: */
250
      if (rc != STAT_OK) {
248
	 Msg2(level, "gethostbyname(\"%s\"): %s", targetname,
249
	      h_errno == NETDB_INTERNAL ? strerror(errno) :
250
	      (char *)hstrerror(h_errno)/*0 h_messages[h_errno-1]*/);
251
252
	 proxyvars->targetaddr = strdup(targetname);
251
	 proxyvars->targetaddr = strdup(targetname);
253
      } else {
252
      } else {
254
#define LEN 16	/* www.xxx.yyy.zzz\0 */
253
#define LEN 16	/* www.xxx.yyy.zzz\0 */
Lines 256-265 int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts, Link Here
256
	    return STAT_RETRYLATER;
255
	    return STAT_RETRYLATER;
257
	 }
256
	 }
258
	 snprintf(proxyvars->targetaddr, LEN, "%u.%u.%u.%u",
257
	 snprintf(proxyvars->targetaddr, LEN, "%u.%u.%u.%u",
259
		  (unsigned char)host->h_addr_list[0][0],
258
		  ((unsigned char *)&host.ip4.sin_addr.s_addr)[0],
260
		  (unsigned char)host->h_addr_list[0][1],
259
		  ((unsigned char *)&host.ip4.sin_addr.s_addr)[1],
261
		  (unsigned char)host->h_addr_list[0][2],
260
		  ((unsigned char *)&host.ip4.sin_addr.s_addr)[2],
262
		  (unsigned char)host->h_addr_list[0][3]);
261
		  ((unsigned char *)&host.ip4.sin_addr.s_addr)[3]);
263
#undef LEN
262
#undef LEN
264
      }
263
      }
265
   } else {
264
   } else {

Return to bug 703212