merged: compile problem caused by size_t/socklen_t mismatch; an invalid close() operation was performed

This commit is contained in:
Gerhard Rieger 2009-05-06 08:28:53 +02:00
parent e0c0e66748
commit 448fa74706
4 changed files with 40 additions and 34 deletions

View file

@ -9,6 +9,12 @@ corrections:
socat crashed on systems without setenv() (esp. SunOS up to Solaris 9);
thanks to Todd Stansell for reporting this bug
with unidirectional EXEC and SYSTEM a close() operation was performed
on a random number which could result in hanging e.a.
fixed a compile problem caused by size_t/socklen_t mismatch on 64bit
systems
####################### V 1.7.1.0:
new features:

View file

@ -1 +1 @@
"1.7.1.0+sigsegv+ftruncate64+fixsetenv"
"1.7.1.0+sigsegv+ftruncate64+fixsetenv+amd64+uniexec"

View file

@ -554,8 +554,8 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
} else
#endif /* HAVE_PTY */
if (usepipes) {
Close(rdpip[1]);
Close(wrpip[0]);
if (rw == XIO_RDONLY) Close(rdpip[1]);
if (rw == XIO_WRONLY) Close(wrpip[0]);
} else {
Close(sv[1]);
}

View file

@ -214,7 +214,7 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
int proto;
int socktype = SOCK_STREAM;
int needbind = 0;
union sockaddr_union them; socklen_t themlen;
union sockaddr_union them; socklen_t themlen; size_t themsize;
union sockaddr_union us; socklen_t uslen = sizeof(us);
int result;
@ -243,16 +243,16 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
applyopts(-1, opts, PH_INIT);
applyopts(-1, opts, PH_EARLY);
themlen = 0;
themsize = 0;
if ((result =
dalan(address, (char *)&them.soa.sa_data, &themlen, sizeof(them)))
dalan(address, (char *)&them.soa.sa_data, &themsize, sizeof(them)))
< 0) {
Error1("data too long: \"%s\"", address);
} else if (result > 0) {
Error1("syntax error in \"%s\"", address);
}
them.soa.sa_family = pf;
themlen +=
themlen = themsize +
#if HAVE_STRUCT_SOCKADDR_SALEN
sizeof(them.soa.sa_len) +
#endif
@ -294,7 +294,7 @@ int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts,
int pf;
int proto;
int socktype = SOCK_STREAM;
union sockaddr_union us; socklen_t uslen;
union sockaddr_union us; socklen_t uslen; size_t ussize;
struct opt *opts0;
int result;
@ -320,15 +320,15 @@ int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts,
xfd->howtoend = END_SHUTDOWN;
socket_init(0, &us);
uslen = 0;
ussize = 0;
if ((result =
dalan(usname, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
dalan(usname, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
< 0) {
Error1("data too long: \"%s\"", usname);
} else if (result > 0) {
Error1("syntax error in \"%s\"", usname);
}
uslen += sizeof(us.soa.sa_family)
uslen = ussize + sizeof(us.soa.sa_family)
#if HAVE_STRUCT_SOCKADDR_SALEN
+ sizeof(us.soa.sa_len)
#endif
@ -381,8 +381,8 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
xiosingle_t *xfd = &xxfd->stream;
char *garbage;
union sockaddr_union us = {{0}};
socklen_t uslen = 0;
socklen_t themlen = 0;
socklen_t uslen = 0; size_t ussize;
size_t themsize;
int pf;
int socktype = SOCK_RAW;
int proto;
@ -411,16 +411,16 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
xfd->howtoend = END_SHUTDOWN;
xfd->peersa.soa.sa_family = pf;
themlen = 0;
themsize = 0;
if ((result =
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themlen,
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themsize,
sizeof(xfd->peersa)))
< 0) {
Error1("data too long: \"%s\"", address);
} else if (result > 0) {
Error1("syntax error in \"%s\"", address);
}
xfd->salen = themlen + sizeof(sa_family_t)
xfd->salen = themsize + sizeof(sa_family_t)
#if HAVE_STRUCT_SOCKADDR_SALEN
+ sizeof(xfd->peersa.soa.sa_len)
#endif
@ -428,7 +428,7 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
#if HAVE_STRUCT_SOCKADDR_SALEN
xfd->peersa.soa.sa_len =
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
themlen;
themsize;
#endif
/* ...res_opts[] */
@ -442,16 +442,16 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
xfd->dtype = XIODATA_RECVFROM;
if (retropt_string(opts, OPT_BIND, &bindstring) == 0) {
uslen = 0;
ussize = 0;
if ((result =
dalan(bindstring, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
dalan(bindstring, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
< 0) {
Error1("data too long: \"%s\"", bindstring);
} else if (result > 0) {
Error1("syntax error in \"%s\"", bindstring);
}
us.soa.sa_family = pf;
uslen += sizeof(sa_family_t)
uslen = ussize + sizeof(sa_family_t)
#if HAVE_STRUCT_SOCKADDR_SALEN
+ sizeof(us.soa.sa_len)
#endif
@ -477,7 +477,7 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
const char *address = argv[4];
char *garbage;
union sockaddr_union *us = &xfd->para.socket.la;
socklen_t uslen = sizeof(*us);
socklen_t uslen; size_t ussize;
int pf, socktype, proto;
char *rangename;
int result;
@ -508,16 +508,16 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
xfd->howtoend = END_NONE;
uslen = 0;
ussize = 0;
if ((result =
dalan(address, (char *)&us->soa.sa_data, &uslen, sizeof(*us)))
dalan(address, (char *)&us->soa.sa_data, &ussize, sizeof(*us)))
< 0) {
Error1("data too long: \"%s\"", address);
} else if (result > 0) {
Error1("syntax error in \"%s\"", address);
}
us->soa.sa_family = pf;
uslen += sizeof(us->soa.sa_family)
uslen = ussize + sizeof(us->soa.sa_family)
#if HAVE_STRUCT_SOCKADDR_SALEN
+ sizeof(us->soa.sa_len);
#endif
@ -554,7 +554,7 @@ int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
const char *address = argv[4];
char *garbage;
union sockaddr_union us;
socklen_t uslen = sizeof(us);
socklen_t uslen; size_t ussize;
int pf, socktype, proto;
char *rangename;
int result;
@ -585,16 +585,16 @@ int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
xfd->howtoend = END_NONE;
uslen = 0;
ussize = 0;
if ((result =
dalan(address, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
dalan(address, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
< 0) {
Error1("data too long: \"%s\"", address);
} else if (result > 0) {
Error1("syntax error in \"%s\"", address);
}
us.soa.sa_family = pf;
uslen += sizeof(sa_family_t)
uslen = ussize + sizeof(sa_family_t)
#if HAVE_STRUCT_SOCKADDR_SALEN
+sizeof(us.soa.sa_len)
#endif
@ -633,7 +633,7 @@ int xioopen_socket_datagram(int argc, const char *argv[], struct opt *opts,
const char *address = argv[4];
char *garbage;
char *rangename;
socklen_t themlen;
size_t themsize;
int pf;
int result;
@ -653,20 +653,20 @@ int xioopen_socket_datagram(int argc, const char *argv[], struct opt *opts,
xfd->howtoend = END_SHUTDOWN;
xfd->peersa.soa.sa_family = pf;
themlen = 0;
themsize = 0;
if ((result =
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themlen,
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themsize,
sizeof(xfd->peersa)))
< 0) {
Error1("data too long: \"%s\"", address);
} else if (result > 0) {
Error1("syntax error in \"%s\"", address);
}
xfd->salen = themlen + sizeof(sa_family_t);
xfd->salen = themsize + sizeof(sa_family_t);
#if HAVE_STRUCT_SOCKADDR_SALEN
xfd->peersa.soa.sa_len =
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
themlen;
themsize;
#endif
if ((result =