linux-user: remove duplicate tswap32() from do_getsockopt()
PATCH 1/1 linux-user: remove duplicate tswap32() from do_getsockopt()
This issue has been detected with tests/linux-tests.c:
linux-test.c:330: getsockopt
327 len = sizeof(val); 328 chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); 329 if (val != SOCK_STREAM)
330 error("getsockopt");
In linux-user/syscall.c:do_getsockopt(), we have:
...
val = tswap32(val);
...
if (put_user_u32(val, optval_addr))...
whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".
So the "val = tswap32(val);" is useless and wrong.
This patch removes it.
--- linux-user/syscall.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
linux-user/syscall.c +0 -1
@@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, ret =get_errno (getsockopt (sockfd, level, optname, &val, &lv));if (ret <0 )return ret; - val =tswap32 (val);if (len > lv) len = lv;if (len ==4 ) {
Signature · 1 line
1.5.6.5
Quoted 14 lines · Laurent Vivier
This issue has been detected with
tests/linux-tests.c:linux-test.c:330: getsockopt
327 len = sizeof(val); 328 chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); 329 if (val != SOCK_STREAM)330
error("getsockopt");In linux-user/syscall.c:do_getsockopt(), we have:
...val = tswap32(val); ... if (put_user_u32(val, optval_addr))
Quoted 7 lines
...
whereas "
put_user_u32" calls in the end "__put_user" which uses "tswap32".So the "val = tswap32(val);" is useless and wrong.
This patch removes it.
makes sense, added to my tree. I think there might be quite a few broken swapping going around..
Quoted 21 lines
Signed-off-by Laurent Vivier <[email protected]>--- linux-user/syscall.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)linux-user/syscall.c +0
-1@@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, ret =get_errno (getsockopt (sockfd, level, optname, &val, &lv));if (ret <0 )return ret; - val =tswap32 (val);if (len > lv) len = lv;if (len ==4 ) {Signature · 1 line
1.5.6.5
Quoted 17 lines · Riku Voipio
Quoted 16 lines · Laurent Vivier
This issue has been detected with
tests/linux-tests.c:linux-test.c:330: getsockopt
327 len = sizeof(val); 328 chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len)); 329 if (val != SOCK_STREAM)330
error("getsockopt");In linux-user/syscall.c:do_getsockopt(), we have:
...val = tswap32(val); ... if (put_user_u32(val, optval_addr))...
Quoted 8 lines
Quoted 5 lines
whereas "
put_user_u32" calls in the end "__put_user" which uses "tswap32".So the "val = tswap32(val);" is useless and wrong.
This patch removes it.
makes sense, added to my tree. I think there might be quite a few broken swapping going around..
Thank you.
I'd like to see this in the qemu reference git tree, should I resend it ?
Quoted 5 lines
Quoted 5 lines
Signed-off-by Laurent Vivier <[email protected]>--- linux-user/syscall.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
Quoted 15 lines
Quoted 15 lines
linux-user/syscall.c +0
-1@@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, ret =get_errno (getsockopt (sockfd, level, optname, &val, &lv));if (ret <0 )return ret; - val =tswap32 (val);if (len > lv) len = lv;if (len ==4 ) {Signature · 1 line
1.5.6.5
Regards,
Laurent
Signature · 3 lines
--------------------- [email protected] ---------------------- "Tout ce qui est impossible reste à accomplir" Jules Verne "Things are only impossible until they're not" Jean-Luc Picard