瀏覽代碼

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 <[email protected]>
Felix Fietkau 1 天之前
父節點
當前提交
2256cfac68
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      package/network/utils/wireguard-tools/files/wireguard.uc

+ 1 - 1
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);
 		}