Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
qemu.3217
0084-dump-fill-in-the-flat-header-signat.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0084-dump-fill-in-the-flat-header-signat.patch of Package qemu.3217
From fab845a4dfe285f543a42bb755c5d61b28d0a19f Mon Sep 17 00:00:00 2001 From: Laszlo Ersek <lersek@redhat.com> Date: Tue, 20 May 2014 13:39:41 +0200 Subject: [PATCH] dump: fill in the flat header signature more pleasingly to the eye The "mh.signature" array field has size 16, and is zeroed by the preceding memset(). MAKEDUMPFILE_SIGNATURE expands to a string literal with string length 12 (size 13). There's no need to measure the length of MAKEDUMPFILE_SIGNATURE at runtime, nor for the extra zero-filling of "mh.signature" with strncpy(). Use memcpy() with MIN(sizeof, sizeof) for robustness (which is an integer constant expression, evaluable at compile time.) Approximately-suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> --- dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dump.c b/dump.c index e56b7cf..ac4505e 100644 --- a/dump.c +++ b/dump.c @@ -716,8 +716,8 @@ static int write_start_flat_header(int fd) int ret = 0; memset(&mh, 0, sizeof(mh)); - strncpy(mh.signature, MAKEDUMPFILE_SIGNATURE, - strlen(MAKEDUMPFILE_SIGNATURE)); + memcpy(mh.signature, MAKEDUMPFILE_SIGNATURE, + MIN(sizeof mh.signature, sizeof MAKEDUMPFILE_SIGNATURE)); mh.type = cpu_to_be64(TYPE_FLAT_HEADER); mh.version = cpu_to_be64(VERSION_FLAT_HEADER);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor