Skip to contentSkip to conversation

net: ipv6: Fixed IPv6 string to address conversion off-by-one error

PATCH In review [email protected] 3 participants 3 messages Jan 13, 2023 – Feb 3, 2023 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipv6: Fixed IPv6 string to address conversion off-by-one error

From: Ehsan Mohandesi <[email protected]>

One extra character was being checked in the IPv6 string which caused the last character of the address to be neither '\0' nor ':'. This raises an error condition and causes the function to always return an error. This issue was resolved by this fix.

---
 net/tftp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/tftp.c +1 -1
index c780c33..328fd90 100644
@@ -837,7 +837,7 @@ void tftp_start(enum proto_t protocol)
 			e = strchr(net_boot_file_name, ']');
 			len = e - s;
 			if (s && e) {
-				string_to_ip6(s + 1, len, &tftp_remote_ip6);
+				string_to_ip6(s + 1, len - 1, &tftp_remote_ip6);
 				strlcpy(tftp_filename, e + 2, MAX_LEN);
 			} else {
 				strlcpy(tftp_filename, net_boot_file_name, MAX_LEN);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · On Fri, 2023-01-13 at 09:27 -0800, [email protected] wrote:

From: Ehsan Mohandesi <[email protected]>

One extra character was being checked in the IPv6 string which caused the
last character of the address to be neither '\0' nor ':'. This raises an
error condition and causes the function to always return an error. This
issue was resolved by this fix.

---
 net/tftp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/tftp.c +1 -1
index c780c33..328fd90 100644
@@ -837,7 +837,7 @@ void tftp_start(enum proto_t protocol)
 			e = strchr(net_boot_file_name, ']');
 			len = e - s;
 			if (s && e) {
-				string_to_ip6(s + 1, len,
 &tftp_remote_ip6);
+				string_to_ip6(s + 1, len - 1,
 &tftp_remote_ip6);
 				strlcpy(tftp_filename, e + 2, MAX_LEN);
net/tftp.c +0 -0
 			} else {
 				strlcpy(tftp_filename,
Quoted 1 line

net_boot_file_name, MAX_LEN);

#2 lore raw
In reply to [email protected]
Quoted 9 lines · On Fri, Jan 13, 2023 at 09:27:41AM -0800, [email protected] wrote:

From: Ehsan Mohandesi <[email protected]>

One extra character was being checked in the IPv6 string which caused the last character of the address to be neither '\0' nor ':'. This raises an error condition and causes the function to always return an error. This issue was resolved by this fix.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom