2012-12-13 14:31:35 +01:00
|
|
|
From: Alexander Graf <agraf@suse.de>
|
|
|
|
Date: Thu, 13 Dec 2012 14:29:22 +0100
|
2019-01-04 22:08:16 +01:00
|
|
|
Subject: linux-user: lseek: explicitly cast non-set offsets to signed
|
2012-12-13 14:31:35 +01:00
|
|
|
|
2013-07-16 04:49:49 +02:00
|
|
|
When doing lseek, SEEK_SET indicates that the offset is an unsigned variable.
|
|
|
|
Other seek types have parameters that can be negative.
|
2012-12-13 14:31:35 +01:00
|
|
|
|
|
|
|
When converting from 32bit to 64bit parameters, we need to take this into
|
2013-07-16 04:49:49 +02:00
|
|
|
account and enable SEEK_END and SEEK_CUR to be negative, while SEEK_SET stays
|
|
|
|
absolute positioned which we need to maintain as unsigned.
|
2012-12-13 14:31:35 +01:00
|
|
|
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
|
|
---
|
2014-01-17 23:04:30 +01:00
|
|
|
linux-user/syscall.c | 9 +++++++--
|
|
|
|
1 file changed, 7 insertions(+), 2 deletions(-)
|
2012-12-13 14:31:35 +01:00
|
|
|
|
|
|
|
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
|
2022-05-27 14:52:53 +02:00
|
|
|
index 381066e788eb36c1d6ca5b872353..7fe3a69c7cd860d7c1a8ea88a48d 100644
|
2012-12-13 14:31:35 +01:00
|
|
|
--- a/linux-user/syscall.c
|
|
|
|
+++ b/linux-user/syscall.c
|
2022-05-27 14:52:53 +02:00
|
|
|
@@ -8701,8 +8701,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_ulong arg1,
|
2018-12-06 22:20:59 +01:00
|
|
|
return ret;
|
2012-12-13 14:31:35 +01:00
|
|
|
#endif
|
2018-12-06 22:20:59 +01:00
|
|
|
#ifdef TARGET_NR_lseek
|
2012-12-13 14:31:35 +01:00
|
|
|
- case TARGET_NR_lseek:
|
2018-12-06 22:20:59 +01:00
|
|
|
- return get_errno(lseek(arg1, arg2, arg3));
|
2012-12-13 14:31:35 +01:00
|
|
|
+ case TARGET_NR_lseek: {
|
|
|
|
+ off_t off = arg2;
|
2013-07-16 04:49:49 +02:00
|
|
|
+ if (arg3 != SEEK_SET) {
|
2012-12-13 14:31:35 +01:00
|
|
|
+ off = (abi_long)arg2;
|
|
|
|
+ }
|
2018-12-06 22:20:59 +01:00
|
|
|
+ return get_errno(lseek(arg1, off, arg3));
|
2012-12-13 14:31:35 +01:00
|
|
|
+ }
|
2018-12-06 22:20:59 +01:00
|
|
|
#endif
|
2012-12-13 14:31:35 +01:00
|
|
|
#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
|
|
|
|
/* Alpha specific */
|