summaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2010-09-18 05:53:14 +0000
committerBlue Swirl <blauwirbel@gmail.com>2010-09-18 05:53:14 +0000
commit3872425343439555e543cd606c44a79dbcc168d4 (patch)
tree496137982866b606182dc739f64512e5ac477ecb /linux-user
parent093209cd681fe9fb65bd8a1c2ff711b8168bbfcd (diff)
downloadqemu-3872425343439555e543cd606c44a79dbcc168d4.tar.gz
linux-user: fix socklen_t comparisons
On many systems, socklen_t is defined as unsigned. This means that checks for negative values are not meaningful. Fix by explicitly casting to a signed integer. This also avoids some warnings with GCC flag -Wtype-limits. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0ebe7e1c26..d44f512ed3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1551,8 +1551,9 @@ static abi_long do_bind(int sockfd, abi_ulong target_addr,
void *addr;
abi_long ret;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
addr = alloca(addrlen+1);
@@ -1570,8 +1571,9 @@ static abi_long do_connect(int sockfd, abi_ulong target_addr,
void *addr;
abi_long ret;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
addr = alloca(addrlen);
@@ -1656,8 +1658,9 @@ static abi_long do_accept(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EINVAL;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
return -TARGET_EINVAL;
@@ -1684,8 +1687,9 @@ static abi_long do_getpeername(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
return -TARGET_EFAULT;
@@ -1712,8 +1716,9 @@ static abi_long do_getsockname(int fd, abi_ulong target_addr,
if (get_user_u32(addrlen, target_addrlen_addr))
return -TARGET_EFAULT;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
if (!access_ok(VERIFY_WRITE, target_addr, addrlen))
return -TARGET_EFAULT;
@@ -1753,8 +1758,9 @@ static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,
void *host_msg;
abi_long ret;
- if (addrlen < 0)
+ if ((int)addrlen < 0) {
return -TARGET_EINVAL;
+ }
host_msg = lock_user(VERIFY_READ, msg, len, 1);
if (!host_msg)
@@ -1792,7 +1798,7 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, size_t len, int flags,
ret = -TARGET_EFAULT;
goto fail;
}
- if (addrlen < 0) {
+ if ((int)addrlen < 0) {
ret = -TARGET_EINVAL;
goto fail;
}