mirror of
https://repo.or.cz/socat.git
synced 2024-12-23 07:52:32 +00:00
compile problem caused by size_t/socklen_t mismatch
This commit is contained in:
parent
a8f6d853de
commit
cedd67dad0
2 changed files with 38 additions and 32 deletions
6
CHANGES
6
CHANGES
|
@ -6,6 +6,12 @@ corrections:
|
||||||
|
|
||||||
ftruncate64 cut its argument to 32 bits on systems with 32 bit long type
|
ftruncate64 cut its argument to 32 bits on systems with 32 bit long type
|
||||||
|
|
||||||
|
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 2.0.0-b7:
|
####################### V 2.0.0-b7:
|
||||||
|
|
||||||
security:
|
security:
|
||||||
|
|
64
xio-socket.c
64
xio-socket.c
|
@ -1,5 +1,5 @@
|
||||||
/* source: xio-socket.c */
|
/* source: xio-socket.c */
|
||||||
/* Copyright Gerhard Rieger 2001-2009 */
|
/* Copyright Gerhard Rieger 2001-2012 */
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
/* this file contains the source for socket related functions, and the
|
/* this file contains the source for socket related functions, and the
|
||||||
|
@ -245,7 +245,7 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
|
||||||
int proto;
|
int proto;
|
||||||
int socktype = SOCK_STREAM;
|
int socktype = SOCK_STREAM;
|
||||||
int needbind = 0;
|
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);
|
union sockaddr_union us; socklen_t uslen = sizeof(us);
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -273,16 +273,16 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
|
||||||
applyopts(-1, opts, PH_INIT);
|
applyopts(-1, opts, PH_INIT);
|
||||||
applyopts(-1, opts, PH_EARLY);
|
applyopts(-1, opts, PH_EARLY);
|
||||||
|
|
||||||
themlen = 0;
|
themsize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(address, (char *)&them.soa.sa_data, &themlen, sizeof(them)))
|
dalan(address, (char *)&them.soa.sa_data, &themsize, sizeof(them)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", address);
|
Error1("data too long: \"%s\"", address);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", address);
|
Error1("syntax error in \"%s\"", address);
|
||||||
}
|
}
|
||||||
them.soa.sa_family = pf;
|
them.soa.sa_family = pf;
|
||||||
themlen +=
|
themlen = themsize +
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
sizeof(them.soa.sa_len) +
|
sizeof(them.soa.sa_len) +
|
||||||
#endif
|
#endif
|
||||||
|
@ -326,7 +326,7 @@ int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts,
|
||||||
int pf;
|
int pf;
|
||||||
int proto;
|
int proto;
|
||||||
int socktype = SOCK_STREAM;
|
int socktype = SOCK_STREAM;
|
||||||
union sockaddr_union us; socklen_t uslen;
|
union sockaddr_union us; socklen_t uslen; size_t ussize;
|
||||||
struct opt *opts0;
|
struct opt *opts0;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -351,15 +351,15 @@ int xioopen_socket_listen(int argc, const char *argv[], struct opt *opts,
|
||||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||||
|
|
||||||
socket_init(0, &us);
|
socket_init(0, &us);
|
||||||
uslen = 0;
|
ussize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(usname, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
|
dalan(usname, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", usname);
|
Error1("data too long: \"%s\"", usname);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", usname);
|
Error1("syntax error in \"%s\"", usname);
|
||||||
}
|
}
|
||||||
uslen += sizeof(us.soa.sa_family)
|
uslen = ussize + sizeof(us.soa.sa_family)
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
+ sizeof(us.soa.sa_len)
|
+ sizeof(us.soa.sa_len)
|
||||||
#endif
|
#endif
|
||||||
|
@ -420,8 +420,8 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
|
||||||
int rw = (xioflags&XIO_ACCMODE);
|
int rw = (xioflags&XIO_ACCMODE);
|
||||||
char *garbage;
|
char *garbage;
|
||||||
union sockaddr_union us = {{0}};
|
union sockaddr_union us = {{0}};
|
||||||
socklen_t uslen = 0;
|
socklen_t uslen = 0; size_t ussize;
|
||||||
socklen_t themlen = 0;
|
size_t themsize;
|
||||||
int pf;
|
int pf;
|
||||||
int socktype = SOCK_RAW;
|
int socktype = SOCK_RAW;
|
||||||
int proto;
|
int proto;
|
||||||
|
@ -449,16 +449,16 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
|
||||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||||
|
|
||||||
xfd->peersa.soa.sa_family = pf;
|
xfd->peersa.soa.sa_family = pf;
|
||||||
themlen = 0;
|
themsize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themlen,
|
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themsize,
|
||||||
sizeof(xfd->peersa)))
|
sizeof(xfd->peersa)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", address);
|
Error1("data too long: \"%s\"", address);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", address);
|
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
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
+ sizeof(xfd->peersa.soa.sa_len)
|
+ sizeof(xfd->peersa.soa.sa_len)
|
||||||
#endif
|
#endif
|
||||||
|
@ -466,7 +466,7 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
xfd->peersa.soa.sa_len =
|
xfd->peersa.soa.sa_len =
|
||||||
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
|
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
|
||||||
themlen;
|
themsize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ...res_opts[] */
|
/* ...res_opts[] */
|
||||||
|
@ -480,16 +480,16 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
|
||||||
xfd->dtype = XIODATA_RECVFROM;
|
xfd->dtype = XIODATA_RECVFROM;
|
||||||
|
|
||||||
if (retropt_string(opts, OPT_BIND, &bindstring) == 0) {
|
if (retropt_string(opts, OPT_BIND, &bindstring) == 0) {
|
||||||
uslen = 0;
|
ussize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(bindstring, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
|
dalan(bindstring, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", bindstring);
|
Error1("data too long: \"%s\"", bindstring);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", bindstring);
|
Error1("syntax error in \"%s\"", bindstring);
|
||||||
}
|
}
|
||||||
us.soa.sa_family = pf;
|
us.soa.sa_family = pf;
|
||||||
uslen += sizeof(sa_family_t)
|
uslen = ussize + sizeof(sa_family_t)
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
+ sizeof(us.soa.sa_len)
|
+ sizeof(us.soa.sa_len)
|
||||||
#endif
|
#endif
|
||||||
|
@ -521,7 +521,7 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
|
||||||
const char *address = argv[4];
|
const char *address = argv[4];
|
||||||
char *garbage;
|
char *garbage;
|
||||||
union sockaddr_union *us = &xfd->para.socket.la;
|
union sockaddr_union *us = &xfd->para.socket.la;
|
||||||
socklen_t uslen = sizeof(*us);
|
socklen_t uslen; size_t ussize;
|
||||||
int pf, socktype, proto;
|
int pf, socktype, proto;
|
||||||
char *rangename;
|
char *rangename;
|
||||||
int result;
|
int result;
|
||||||
|
@ -551,16 +551,16 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
|
||||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||||
|
|
||||||
uslen = 0;
|
ussize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(address, (char *)&us->soa.sa_data, &uslen, sizeof(*us)))
|
dalan(address, (char *)&us->soa.sa_data, &ussize, sizeof(*us)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", address);
|
Error1("data too long: \"%s\"", address);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", address);
|
Error1("syntax error in \"%s\"", address);
|
||||||
}
|
}
|
||||||
us->soa.sa_family = pf;
|
us->soa.sa_family = pf;
|
||||||
uslen += sizeof(us->soa.sa_family)
|
uslen = ussize + sizeof(us->soa.sa_family)
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
+ sizeof(us->soa.sa_len);
|
+ sizeof(us->soa.sa_len);
|
||||||
#endif
|
#endif
|
||||||
|
@ -597,7 +597,7 @@ int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
|
||||||
const char *address = argv[4];
|
const char *address = argv[4];
|
||||||
char *garbage;
|
char *garbage;
|
||||||
union sockaddr_union us;
|
union sockaddr_union us;
|
||||||
socklen_t uslen = sizeof(us);
|
socklen_t uslen; size_t ussize;
|
||||||
int pf, socktype, proto;
|
int pf, socktype, proto;
|
||||||
char *rangename;
|
char *rangename;
|
||||||
int result;
|
int result;
|
||||||
|
@ -627,16 +627,16 @@ int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
|
||||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||||
|
|
||||||
uslen = 0;
|
ussize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(address, (char *)&us.soa.sa_data, &uslen, sizeof(us)))
|
dalan(address, (char *)&us.soa.sa_data, &ussize, sizeof(us)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", address);
|
Error1("data too long: \"%s\"", address);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", address);
|
Error1("syntax error in \"%s\"", address);
|
||||||
}
|
}
|
||||||
us.soa.sa_family = pf;
|
us.soa.sa_family = pf;
|
||||||
uslen += sizeof(sa_family_t)
|
uslen = ussize + sizeof(sa_family_t)
|
||||||
#if HAVE_STRUCT_SOCKADDR_SALEN
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
+sizeof(us.soa.sa_len)
|
+sizeof(us.soa.sa_len)
|
||||||
#endif
|
#endif
|
||||||
|
@ -675,7 +675,7 @@ int xioopen_socket_datagram(int argc, const char *argv[], struct opt *opts,
|
||||||
const char *address = argv[4];
|
const char *address = argv[4];
|
||||||
char *garbage;
|
char *garbage;
|
||||||
char *rangename;
|
char *rangename;
|
||||||
socklen_t themlen;
|
size_t themsize;
|
||||||
int pf;
|
int pf;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -694,20 +694,20 @@ int xioopen_socket_datagram(int argc, const char *argv[], struct opt *opts,
|
||||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||||
|
|
||||||
xfd->peersa.soa.sa_family = pf;
|
xfd->peersa.soa.sa_family = pf;
|
||||||
themlen = 0;
|
themsize = 0;
|
||||||
if ((result =
|
if ((result =
|
||||||
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themlen,
|
dalan(address, (char *)&xfd->peersa.soa.sa_data, &themsize,
|
||||||
sizeof(xfd->peersa)))
|
sizeof(xfd->peersa)))
|
||||||
< 0) {
|
< 0) {
|
||||||
Error1("data too long: \"%s\"", address);
|
Error1("data too long: \"%s\"", address);
|
||||||
} else if (result > 0) {
|
} else if (result > 0) {
|
||||||
Error1("syntax error in \"%s\"", address);
|
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
|
#if HAVE_STRUCT_SOCKADDR_SALEN
|
||||||
xfd->peersa.soa.sa_len =
|
xfd->peersa.soa.sa_len =
|
||||||
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
|
sizeof(xfd->peersa.soa.sa_len) + sizeof(xfd->peersa.soa.sa_family) +
|
||||||
themlen;
|
themsize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((result =
|
if ((result =
|
||||||
|
|
Loading…
Reference in a new issue