[openwrt/openwrt] wireguard-tools: fix string indexing in endpoint host check

LEDE Commits lede-commits at lists.infradead.org
Fri Feb 20 10:10:28 PST 2026


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/2256cfac685f9bc47bde8ef819076c3933593292

commit 2256cfac685f9bc47bde8ef819076c3933593292
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Feb 20 18:05:45 2026 +0000

    wireguard-tools: fix string indexing in endpoint host check
    
    Use substr() instead of array index syntax to access the first
    character of the endpoint host string, as ucode does not support
    array-style indexing on strings.
    
    Fixes: https://github.com/openwrt/openwrt/issues/22116
    Fixes: 8f977b4a4055 ("wireguard-tools: fix handling of multi-value config options")
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/network/utils/wireguard-tools/files/wireguard.uc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/network/utils/wireguard-tools/files/wireguard.uc b/package/network/utils/wireguard-tools/files/wireguard.uc
index c74512909f..9f99904812 100644
--- a/package/network/utils/wireguard-tools/files/wireguard.uc
+++ b/package/network/utils/wireguard-tools/files/wireguard.uc
@@ -123,7 +123,7 @@ function proto_setup(proto) {
 
 		if (peer.endpoint_host) {
 			let eph = peer.endpoint_host;
-			if (index(eph, ':') >= 0 && eph[0] != '[')
+			if (index(eph, ':') >= 0 && substr(eph, 0, 1) != '[')
 				eph = sprintf('[%s]', eph);
 			wg_config += sprintf('Endpoint=%s:%s\n', eph, peer.endpoint_port);
 		}




More information about the lede-commits mailing list