[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/8] linux-user: Don't write off end of new_utsname
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 5/8] linux-user: Don't write off end of new_utsname buffer |
Date: |
Tue, 12 Jul 2016 13:02:16 +0100 |
Use g_strlcpy() rather than strcpy() to copy the uname string
into the structure we return to the guest for the uname syscall.
This avoids overrunning the buffer if the user passed us an
overlong string via the QEMU command line.
We fix a comment typo while we're in the neighbourhood.
Signed-off-by: Peter Maydell <address@hidden>
---
linux-user/syscall.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 37d26bb..f849a5d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8911,12 +8911,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
goto efault;
ret = get_errno(sys_uname(buf));
if (!is_error(ret)) {
- /* Overrite the native machine name with whatever is being
+ /* Overwrite the native machine name with whatever is being
emulated. */
strcpy (buf->machine, cpu_to_uname_machine(cpu_env));
/* Allow the user to override the reported release. */
- if (qemu_uname_release && *qemu_uname_release)
- strcpy (buf->release, qemu_uname_release);
+ if (qemu_uname_release && *qemu_uname_release) {
+ g_strlcpy(buf->release, qemu_uname_release,
+ sizeof(buf->release));
+ }
}
unlock_user_struct(buf, arg1, 1);
}
--
1.9.1
- [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 1/8] linux-user: Pass missing MAP_ANONYMOUS to target_mmap() call, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 2/8] linux-user: Check lock_user() return value for NULL, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 5/8] linux-user: Don't write off end of new_utsname buffer,
Peter Maydell <=
- [Qemu-devel] [PATCH 7/8] linux-user: Use glib malloc functions in load_symbols(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 6/8] linux-user: Check dump_write() return in elf_core_dump(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 4/8] linux-user: Fix error handling in flatload.c target_pread(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 3/8] linux-user: Fix incorrect use of host errno in do_ioctl_dm(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 8/8] linux-user: Fix memchr() argument in open_self_cmdline(), Peter Maydell, 2016/07/12
- Re: [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits, Paolo Bonzini, 2016/07/12