Patchwork [4/8] pc: Fix unchecked strdup() by switching to fw_cfg_add_string()

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 16, 2013, 1:50 p.m.
Message ID <1358344229-18006-5-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/212519/
State New
Headers show

Comments

Markus Armbruster - Jan. 16, 2013, 1:50 p.m.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/pc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Patch

diff --git a/hw/pc.c b/hw/pc.c
index ba1f19d..bc5c33f 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -693,9 +693,7 @@  static void load_linux(void *fw_cfg,
 
     fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr);
     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);
 
     if (protocol >= 0x202) {
 	stl_p(header+0x228, cmdline_addr);