]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wireguard-tools: fix string indexing in endpoint host check
authorFelix Fietkau <nbd@nbd.name>
Fri, 20 Feb 2026 18:05:45 +0000 (18:05 +0000)
committerFelix Fietkau <nbd@nbd.name>
Fri, 20 Feb 2026 18:10:13 +0000 (19:10 +0100)
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@nbd.name>
package/network/utils/wireguard-tools/files/wireguard.uc

index c74512909f931bfade6a2b6a43dabee2f1d87669..9f99904812f449cc540942719b37cf249e7e9b8a 100644 (file)
@@ -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);
                }