[PATCH] lwip: wget: process legacy url with strncpy
Adriano Cordova
adrianox at gmail.com
Thu Nov 28 15:36:42 CET 2024
Commit 356011f ("lwip: fix code style issues") changed two strncpy calls to
strlcpy calls in the function net/lwip/wget.c:parse_legacy_args, but this
breaks the correct parsing of a legacy url. strlcpy expects the size of the
destination buffer, not of the amount of bytes to be copied, and it will stop
when the buffer ends or when a null is found, but here we want to copy a
specific amount of bytes and there is no null at the end of that specific
amount of bytes. The change is reverted here. Optionally, all the calls to
strlcpy(,,n) could be changed to strlcpy(,,n+1).
Fixes: 356011f ("lwip: fix code style issues")
Signed-off-by: Adriano Cordova <adrianox at gmail.com>
---
net/lwip/wget.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/lwip/wget.c b/net/lwip/wget.c
index 83ae8a6d15..af48d741a4 100644
--- a/net/lwip/wget.c
+++ b/net/lwip/wget.c
@@ -180,7 +180,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)
@@ -191,7 +191,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)
--
2.43.0
More information about the U-Boot
mailing list