allow bind() with addr len >= sizeof(sockaddr_in)

. specifically, if it's struct sockaddr, which is
	  1 byte larger than sockaddr_in
	. unbreaks some applications
	. debugged and solved by Jan Wieck
This commit is contained in:
Ben Gras 2011-08-05 20:55:57 +00:00
parent d477a9ed82
commit 4a8ceeebff

View file

@ -93,7 +93,7 @@ static int _tcp_bind(int sock, const struct sockaddr *address,
struct sockaddr_in *sinp; struct sockaddr_in *sinp;
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *)address;
if (sinp->sin_family != AF_INET || address_len != sizeof(*sinp)) if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{ {
#if DEBUG #if DEBUG
fprintf(stderr, "bind(tcp): sin_family = %d, len = %d\n", fprintf(stderr, "bind(tcp): sin_family = %d, len = %d\n",
@ -133,7 +133,7 @@ static int _udp_bind(int sock, const struct sockaddr *address,
struct sockaddr_in *sinp; struct sockaddr_in *sinp;
sinp= (struct sockaddr_in *)address; sinp= (struct sockaddr_in *)address;
if (sinp->sin_family != AF_INET || address_len != sizeof(*sinp)) if (sinp->sin_family != AF_INET || address_len < sizeof(*sinp))
{ {
#if DEBUG #if DEBUG
fprintf(stderr, "bind(udp): sin_family = %d, len = %d\n", fprintf(stderr, "bind(udp): sin_family = %d, len = %d\n",