mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 21:51:31 +00:00
cmd/pxe.c: Rework initrd and bootargs handling slightly
For the initrd portion of handling our bootm arguments we do not have a sufficiently long enough buffer for some improbable 64bit cases. Expand this buffer to allow for a 64bit address and almost 256MB initrd to be used. Make use of strncpy/strncat when constructing the values here since we know what the worst case valid values are, length wise. Similarly for bootargs themselves, we need to make use of strlen/sizeof and strncpy/strncat to ensure that we don't overflow bootargs itself. Cc: Simon Glass <sjg@chromium.org> Cc: Alexander Graf <agraf@suse.de> Reported-by: Coverity (CID: 131256) Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
c667723ffb
commit
48ee0a87bc
1 changed files with 6 additions and 6 deletions
12
cmd/pxe.c
12
cmd/pxe.c
|
@ -616,7 +616,7 @@ static int label_localboot(struct pxe_label *label)
|
||||||
static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
||||||
{
|
{
|
||||||
char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL };
|
char *bootm_argv[] = { "bootm", NULL, NULL, NULL, NULL };
|
||||||
char initrd_str[22];
|
char initrd_str[28];
|
||||||
char mac_str[29] = "";
|
char mac_str[29] = "";
|
||||||
char ip_str[68] = "";
|
char ip_str[68] = "";
|
||||||
int bootm_argc = 2;
|
int bootm_argc = 2;
|
||||||
|
@ -648,9 +648,9 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
||||||
}
|
}
|
||||||
|
|
||||||
bootm_argv[2] = initrd_str;
|
bootm_argv[2] = initrd_str;
|
||||||
strcpy(bootm_argv[2], env_get("ramdisk_addr_r"));
|
strncpy(bootm_argv[2], env_get("ramdisk_addr_r"), 18);
|
||||||
strcat(bootm_argv[2], ":");
|
strcat(bootm_argv[2], ":");
|
||||||
strcat(bootm_argv[2], env_get("filesize"));
|
strncat(bootm_argv[2], env_get("filesize"), 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
|
if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
|
||||||
|
@ -689,9 +689,9 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label->append)
|
if (label->append)
|
||||||
strcpy(bootargs, label->append);
|
strncpy(bootargs, label->append, sizeof(bootargs));
|
||||||
strcat(bootargs, ip_str);
|
strncat(bootargs, ip_str, sizeof(bootargs) - strlen(bootargs));
|
||||||
strcat(bootargs, mac_str);
|
strncat(bootargs, mac_str, sizeof(bootargs) - strlen(bootargs));
|
||||||
|
|
||||||
cli_simple_process_macros(bootargs, finalbootargs);
|
cli_simple_process_macros(bootargs, finalbootargs);
|
||||||
env_set("bootargs", finalbootargs);
|
env_set("bootargs", finalbootargs);
|
||||||
|
|
Loading…
Add table
Reference in a new issue