aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf/name.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-07-27 17:17:33 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-08-02 13:54:04 +0200
commitf4ffac2f6ad818a96bc524dafc3e19aa7abf1853 (patch)
tree548b247b04403c24626f54036b5d68d2f44be8b4 /conf/name.go
parentinstaller: sign custom actions dll (diff)
downloadwireguard-windows-f4ffac2f6ad818a96bc524dafc3e19aa7abf1853.tar.xz
wireguard-windows-f4ffac2f6ad818a96bc524dafc3e19aa7abf1853.zip
conf: forbid reserved names with extension
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'conf/name.go')
-rw-r--r--conf/name.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/conf/name.go b/conf/name.go
index a4affb48..e3287128 100644
--- a/conf/name.go
+++ b/conf/name.go
@@ -21,11 +21,7 @@ const serviceNameForbidden = "$"
const netshellDllForbidden = "\\/:*?\"<>|\t"
const specialChars = "/\\<>:\"|?*\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x00"
-var allowedNameFormat *regexp.Regexp
-
-func init() {
- allowedNameFormat = regexp.MustCompile("^[a-zA-Z0-9_=+.-]{1,32}$")
-}
+var allowedNameFormat = regexp.MustCompile("^[a-zA-Z0-9_=+.-]{1,32}$")
func isReserved(name string) bool {
if len(name) == 0 {
@@ -35,6 +31,14 @@ func isReserved(name string) bool {
if strings.EqualFold(name, reserved) {
return true
}
+ for i := len(name) - 1; i >= 0; i-- {
+ if name[i] == '.' {
+ if strings.EqualFold(name[:i], reserved) {
+ return true
+ }
+ break
+ }
+ }
}
return false
}