mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
net: lwip: tftp: Fix filename handling
The code to choose the filename to use does not cope with no name set at all. Firstly the test for a name in net_boot_file_name tests the pointer rather than the string it points to. Secondly the cleanup on exit in this case attempts to free a global variable. Fix both issues. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
This commit is contained in:
committed by
Jerome Forissier
parent
47b50fb112
commit
8910efa71b
@@ -279,7 +279,7 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
if (!arg)
|
||||
arg = net_boot_file_name;
|
||||
|
||||
if (arg) {
|
||||
if (*arg) {
|
||||
/* Parse [ip:[port:]]fname */
|
||||
i = 0;
|
||||
while ((*(words + i) = strsep(&arg, ":")))
|
||||
@@ -342,6 +342,7 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
if (tftp_loop(eth_get_dev(), laddr, fname, srvip, port) < 0)
|
||||
ret = CMD_RET_FAILURE;
|
||||
out:
|
||||
free(arg);
|
||||
if (arg != net_boot_file_name)
|
||||
free(arg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user