Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
qemu-linux-user.11147
0463-loader-Add-load_image_size-to-repla.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0463-loader-Add-load_image_size-to-repla.patch of Package qemu-linux-user.11147
From aed3154e28a6f5519daf67fbfae7b38217610214 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: Mon, 21 Jul 2014 13:02:03 +1000 Subject: [PATCH] loader: Add load_image_size() to replace load_image() A subsequent patch to ppc/spapr needs to load the RTAS blob into qemu memory rather than target memory (so it can later be copied into the right spot at machine reset time). I would use load_image() but it is marked deprecated because it doesn't take a buffer size as argument, so let's add load_image_size() that does. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [aik: fixed errors from checkpatch.pl] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Alexander Graf <agraf@suse.de> (cherry picked from commit ea87616d6c44d998affef3d3b9fdfc49d14b8150) [LM: BSC#1130675 CVE-2018-20815] Signed-off-by: Lin Ma <lma@suse.com> --- hw/core/loader.c | 21 +++++++++++++++++++++ include/hw/loader.h | 1 + 2 files changed, 22 insertions(+) diff --git a/hw/core/loader.c b/hw/core/loader.c index a3fc5f629d..2d0cd72a66 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -89,6 +89,27 @@ int load_image(const char *filename, uint8_t *addr) return size; } +/* return the size or -1 if error */ +ssize_t load_image_size(const char *filename, void *addr, size_t size) +{ + int fd; + ssize_t actsize; + + fd = open(filename, O_RDONLY | O_BINARY); + if (fd < 0) { + return -1; + } + + actsize = read(fd, addr, size); + if (actsize < 0) { + close(fd); + return -1; + } + close(fd); + + return actsize; +} + /* read()-like version */ ssize_t read_targphys(const char *name, int fd, hwaddr dst_addr, size_t nbytes) diff --git a/include/hw/loader.h b/include/hw/loader.h index 796cbf9b39..991f84aade 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -13,6 +13,7 @@ */ int get_image_size(const char *filename); int load_image(const char *filename, uint8_t *addr); /* deprecated */ +ssize_t load_image_size(const char *filename, void *addr, size_t size); int load_image_targphys(const char *filename, hwaddr, uint64_t max_sz);
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