qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, aliguori@us.ibm.com, gleb@redhat.com
Subject: [Qemu-devel] [PATCH 5/8] sun4: Fix unchecked strdup() by switching to fw_cfg_add_string()
Date: Wed, 16 Jan 2013 14:50:26 +0100	[thread overview]
Message-ID: <1358344229-18006-6-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1358344229-18006-1-git-send-email-armbru@redhat.com>


Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/sun4m.c | 12 +++---------
 hw/sun4u.c |  4 +---
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/hw/sun4m.c b/hw/sun4m.c
index 6f5de44..4264efd 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -1030,9 +1030,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
     if (kernel_cmdline) {
         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
         pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
-                         (uint8_t*)strdup(kernel_cmdline),
-                         strlen(kernel_cmdline) + 1);
+        fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
                        strlen(kernel_cmdline) + 1);
     } else {
@@ -1676,9 +1674,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
     if (kernel_cmdline) {
         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
         pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
-                         (uint8_t*)strdup(kernel_cmdline),
-                         strlen(kernel_cmdline) + 1);
+        fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
     } else {
         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
     }
@@ -1878,9 +1874,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
     if (kernel_cmdline) {
         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
         pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
-                         (uint8_t*)strdup(kernel_cmdline),
-                         strlen(kernel_cmdline) + 1);
+        fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
     } else {
         fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
     }
diff --git a/hw/sun4u.c b/hw/sun4u.c
index cb75d03..d36acde 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -886,9 +886,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     if (kernel_cmdline) {
         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE,
                        strlen(kernel_cmdline) + 1);
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_CMDLINE_DATA,
-                         (uint8_t*)strdup(kernel_cmdline),
-                         strlen(kernel_cmdline) + 1);
+        fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline);
     } else {
         fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, 0);
     }
-- 
1.7.11.7

  parent reply	other threads:[~2013-01-16 13:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 13:50 [Qemu-devel] [PATCH 0/8] Fixes and cleanups around fw_cfg Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 1/8] fw_cfg: Replace debug prints by tracepoints Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 2/8] fw_cfg: Dumb down fw_cfg_add_*() not to return success / failure Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 3/8] fw_cfg: New fw_cfg_add_string() Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 4/8] pc: Fix unchecked strdup() by switching to fw_cfg_add_string() Markus Armbruster
2013-01-16 13:50 ` Markus Armbruster [this message]
2013-01-16 13:50 ` [Qemu-devel] [PATCH 6/8] pc: Clean up bochs_bios_init()'s (non-)use of sizeof Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 7/8] fw_cfg: Use void *, size_t instead of uint8_t *, uint32_t for blobs Markus Armbruster
2013-01-16 13:50 ` [Qemu-devel] [PATCH 8/8] vl: Use size_t for sizes in get_boot_devices_list() Markus Armbruster
2013-01-17 13:16 ` [Qemu-devel] [PATCH 0/8] Fixes and cleanups around fw_cfg Gleb Natapov
2013-01-19 13:59   ` Blue Swirl

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=1358344229-18006-6-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=gleb@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).