diff options
author | Dmitry Frolov <frolov@swemel.ru> | 2024-06-28 15:39:10 +0300 |
---|---|---|
committer | Song Gao <gaosong@loongson.cn> | 2024-07-12 09:41:18 +0800 |
commit | 5e21b1317f900a574d85e0890ba156078964ba2c (patch) | |
tree | 8c5a3d22d4917b710131c4eebca2c48f35914745 /hw/loongarch | |
parent | 23901b2b721c0576007ab7580da8aa855d6042a9 (diff) |
hw/loongarch/boot.c: fix out-of-bound reading
memcpy() is trying to READ 512 bytes from memory,
pointed by info->kernel_cmdline,
which was (presumable) allocated by g_strdup("");
Found with ASAN, making check with enabled sanitizers.
Signed-off-by: Dmitry Frolov <frolov@swemel.ru>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240628123910.577740-1-frolov@swemel.ru>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Diffstat (limited to 'hw/loongarch')
-rw-r--r-- | hw/loongarch/boot.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index b8e1aa18d5..cb668703bd 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -163,7 +163,7 @@ static void init_cmdline(struct loongarch_boot_info *info, void *p, void *start) info->a0 = 1; info->a1 = cmdline_addr; - memcpy(p, info->kernel_cmdline, COMMAND_LINE_SIZE); + g_strlcpy(p, info->kernel_cmdline, COMMAND_LINE_SIZE); } static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr) |