j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Instead use strdup() so that we can dynamically allocate the string ourselves. As reported by Rob Landley rob@landley.net.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/openbios.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/openbios-devel/arch/sparc32/openbios.c b/openbios-devel/arch/sparc32/openbios.c index 95a5d37..de23a6f 100644 --- a/openbios-devel/arch/sparc32/openbios.c +++ b/openbios-devel/arch/sparc32/openbios.c @@ -835,8 +835,7 @@ static void init_memory(void) static void arch_init( void ) { - static char cmdline[128]; - int size = 0; + char *cmdline; const char *kernel_cmdline; uint32_t temp; uint16_t machine_id; @@ -897,11 +896,11 @@ arch_init( void )
kernel_cmdline = (const char *) fw_cfg_read_i32(FW_CFG_KERNEL_CMDLINE); if (kernel_cmdline) { - size = strlen(kernel_cmdline); - memcpy(cmdline, kernel_cmdline, size); + cmdline = strdup(kernel_cmdline); obp_arg.argv[1] = cmdline; - } - cmdline[size] = '\0'; + } else { + cmdline = strdup(""); + } qemu_cmdline = (uint32_t)cmdline;
/* Setup nvram variables */
Instead use malloc() so that we can dynamically allocate the string ourselves. As reported by Rob Landley rob@landley.net.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc64/openbios.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/openbios-devel/arch/sparc64/openbios.c b/openbios-devel/arch/sparc64/openbios.c index 3b372b9..a6c956a 100644 --- a/openbios-devel/arch/sparc64/openbios.c +++ b/openbios-devel/arch/sparc64/openbios.c @@ -42,9 +42,6 @@ #define NVRAM_OB_START (0) #define NVRAM_OB_SIZE ((0x1fd0 - NVRAM_OB_START) & ~15)
-#define OBIO_CMDLINE_MAX 256 -static char obio_cmdline[OBIO_CMDLINE_MAX]; - static uint8_t idprom[NVRAM_IDPROM_SIZE];
struct hwdef { @@ -370,6 +367,7 @@ static uint8_t qemu_uuid[16];
void arch_nvram_get(char *data) { + char *obio_cmdline; uint32_t size = 0; const struct cpudef *cpu; char buf[256]; @@ -401,12 +399,13 @@ void arch_nvram_get(char *data) kernel_image = fw_cfg_read_i64(FW_CFG_KERNEL_ADDR);
size = fw_cfg_read_i32(FW_CFG_CMDLINE_SIZE); - if (size > OBIO_CMDLINE_MAX - 1) - size = OBIO_CMDLINE_MAX - 1; if (size) { + obio_cmdline = (char *)malloc(size + 1); fw_cfg_read(FW_CFG_CMDLINE_DATA, obio_cmdline, size); + obio_cmdline[size] = '\0'; + } else { + obio_cmdline = strdup(""); } - obio_cmdline[size] = '\0'; qemu_cmdline = (uint64_t)obio_cmdline; cmdline_size = size; boot_device = fw_cfg_read_i16(FW_CFG_BOOT_DEVICE);