From f50ef334f7ec31341a8435bc4dae699d5b7dcadc344d3798e437ca9770951dad Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Thu, 13 Dec 2012 13:31:35 +0000 Subject: [PATCH] - linux-user: fix lseek with SEEK_END OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=125 --- ...-linux-user-lseek-explicitly-cast-en.patch | 38 +++++++++++++++++++ qemu.changes | 5 +++ qemu.spec | 2 + 3 files changed, 45 insertions(+) create mode 100644 0039-linux-user-lseek-explicitly-cast-en.patch diff --git a/0039-linux-user-lseek-explicitly-cast-en.patch b/0039-linux-user-lseek-explicitly-cast-en.patch new file mode 100644 index 00000000..bf1a2fc2 --- /dev/null +++ b/0039-linux-user-lseek-explicitly-cast-en.patch @@ -0,0 +1,38 @@ +From 9b90b7e01f2f4d474e68a43b5f1b2e821dfa8619 Mon Sep 17 00:00:00 2001 +From: Alexander Graf +Date: Thu, 13 Dec 2012 14:29:22 +0100 +Subject: [PATCH] linux-user: lseek: explicitly cast end offsets to signed + +When doing lseek, SEEK_END indicates that the offset is a signed variable +that is usually negative, while and other SEEK indicates that it's unsigned. + +When converting from 32bit to 64bit parameters, we need to take this into +account and enable SEEK_END to be negative, while other SEEKs usually indicate +absolute position which we need to maintain as unsigned. + +Signed-off-by: Alexander Graf +--- + linux-user/syscall.c | 9 +++++++-- + 1 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/linux-user/syscall.c b/linux-user/syscall.c +index a694181..a038cbe 100644 +--- a/linux-user/syscall.c ++++ b/linux-user/syscall.c +@@ -5597,9 +5597,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1, + case TARGET_NR_oldstat: + goto unimplemented; + #endif +- case TARGET_NR_lseek: +- ret = get_errno(lseek(arg1, arg2, arg3)); ++ case TARGET_NR_lseek: { ++ off_t off = arg2; ++ if (arg3 == SEEK_END) { ++ off = (abi_long)arg2; ++ } ++ ret = get_errno(lseek(arg1, off, arg3)); + break; ++ } + #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA) + /* Alpha specific */ + case TARGET_NR_getxpid: diff --git a/qemu.changes b/qemu.changes index 6083595d..b79569eb 100644 --- a/qemu.changes +++ b/qemu.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Dec 13 13:30:57 UTC 2012 - agraf@suse.com + +- linux-user: fix lseek with SEEK_END + ------------------------------------------------------------------- Thu Dec 13 10:47:52 UTC 2012 - agraf@suse.com diff --git a/qemu.spec b/qemu.spec index 4490601f..ae980073 100644 --- a/qemu.spec +++ b/qemu.spec @@ -62,6 +62,7 @@ Patch0035: 0035-Legacy-Patch-kvm-qemu-preXX-dictzip.patch Patch0036: 0036-Legacy-Patch-kvm-qemu-preXX-report-.patch Patch0037: 0037-console-add-question-mark-escape-op.patch Patch0038: 0038-Make-char-muxer-more-robust-wrt-sma.patch +Patch0039: 0039-linux-user-lseek-explicitly-cast-en.patch # this is to make lint happy Source300: rpmlintrc Source302: bridge.conf @@ -218,6 +219,7 @@ run cross-architecture builds. %patch0036 -p1 %patch0037 -p1 %patch0038 -p1 +%patch0039 -p1 %build # build QEMU