diff mbox series

net: lwip: wget: fix legacy syntax

Message ID 20241126144508.501779-1-jerome.forissier@linaro.org
State Accepted
Commit a37064cb2e482739908e76d6a53914301c8bb8ee
Headers show
Series net: lwip: wget: fix legacy syntax | expand

Commit Message

Jerome Forissier Nov. 26, 2024, 2:45 p.m. UTC
Commit 356011f7ac25 ("lwip: fix code style issues") has inadvertently
broken the support for the legacy syntax:

 => wget 192.168.0.16:test.bin
 invalid uri, no file path
 Invalid URL. Use http(s)://

The reason is two calls to strncpy() were replaced by strlcpy() without
paying attention to the fact that they are not equivalent in the present
case. Since we are using a character counter (n) and since we do not
depend on having a properly null-terminated string at each step in the
parsing, strlcpy() is not justified and strncpy() is the right tool for
the job. So use it again.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 net/lwip/wget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Nov. 30, 2024, 11:37 p.m. UTC | #1
On Tue, 26 Nov 2024 15:45:06 +0100, Jerome Forissier wrote:

> Commit 356011f7ac25 ("lwip: fix code style issues") has inadvertently
> broken the support for the legacy syntax:
> 
>  => wget 192.168.0.16:test.bin
>  invalid uri, no file path
>  Invalid URL. Use http(s)://
> 
> [...]

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index 062aa7c44f0..5501ffdd004 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -161,7 +161,7 @@  static int parse_legacy_arg(char *arg, char *nurl, size_t rem)
 
 	if (rem < n)
 		return -1;
-	strlcpy(p, server, n);
+	strncpy(p, server, n);
 	p += n;
 	rem -= n;
 	if (rem < 1)
@@ -172,7 +172,7 @@  static int parse_legacy_arg(char *arg, char *nurl, size_t rem)
 	n = strlen(path);
 	if (rem < n)
 		return -1;
-	strlcpy(p, path, n);
+	strncpy(p, path, n);
 	p += n;
 	rem -= n;
 	if (rem < 1)