Sfoglia il codice sorgente

fix(maskcompat): size xdns domain list from domains alone

CodeQL (go/allocation-size-overflow, alerts #115/#116) flagged the
len(rawDomains)+len(rawResolvers) capacity hint. The sum cannot overflow
in practice, but the hint bought nothing: resolver-derived domains are
deduplicated and append grows the slice as needed.
MHSanaei 12 ore fa
parent
commit
eef1c1eb6a
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      internal/util/maskcompat/xdns.go

+ 1 - 1
internal/util/maskcompat/xdns.go

@@ -34,7 +34,7 @@ func upgradeLegacyXdnsSettings(settings map[string]any) bool {
 	if !hasLegacyXdnsEntry(rawDomains) && !hasLegacyXdnsEntry(rawResolvers) {
 		return false
 	}
-	domains := make([]any, 0, len(rawDomains)+len(rawResolvers))
+	domains := make([]any, 0, len(rawDomains))
 	listed := map[string]bool{}
 	addDomain := func(domain map[string]any) {
 		key, _ := domain["name"].(string)