From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5761] uImage: don't leak file data or file descriptor (Hollis Blanchard)
Date: Thu, 20 Nov 2008 22:02:56 +0000 [thread overview]
Message-ID: <E1L3Hc0-000376-LO@cvs.savannah.gnu.org> (raw)
Revision: 5761
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5761
Author: aliguori
Date: 2008-11-20 22:02:56 +0000 (Thu, 20 Nov 2008)
Log Message:
-----------
uImage: don't leak file data or file descriptor (Hollis Blanchard)
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Modified Paths:
--------------
trunk/loader.c
Modified: trunk/loader.c
===================================================================
--- trunk/loader.c 2008-11-20 16:46:21 UTC (rev 5760)
+++ trunk/loader.c 2008-11-20 22:02:56 UTC (rev 5761)
@@ -354,6 +354,7 @@
uboot_image_header_t h;
uboot_image_header_t *hdr = &h;
uint8_t *data = NULL;
+ int ret = -1;
fd = open(filename, O_RDONLY | O_BINARY);
if (fd < 0)
@@ -361,23 +362,23 @@
size = read(fd, hdr, sizeof(uboot_image_header_t));
if (size < 0)
- goto fail;
+ goto out;
bswap_uboot_header(hdr);
if (hdr->ih_magic != IH_MAGIC)
- goto fail;
+ goto out;
/* TODO: Implement Multi-File images. */
if (hdr->ih_type == IH_TYPE_MULTI) {
fprintf(stderr, "Unable to load multi-file u-boot images\n");
- goto fail;
+ goto out;
}
/* TODO: Implement compressed images. */
if (hdr->ih_comp != IH_COMP_NONE) {
fprintf(stderr, "Unable to load compressed u-boot images\n");
- goto fail;
+ goto out;
}
/* TODO: Check CPU type. */
@@ -391,20 +392,20 @@
*ep = hdr->ih_ep;
data = qemu_malloc(hdr->ih_size);
if (!data)
- goto fail;
+ goto out;
if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
fprintf(stderr, "Error reading file\n");
- goto fail;
+ goto out;
}
cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
- return hdr->ih_size;
+ ret = hdr->ih_size;
-fail:
+out:
if (data)
qemu_free(data);
close(fd);
- return -1;
+ return ret;
}
reply other threads:[~2008-11-20 22:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1L3Hc0-000376-LO@cvs.savannah.gnu.org \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.