fix(upnp): guard against out of index string access (#10834)

Broken responses may have empty path component.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-07-26 18:37:28 +00:00
committed by GitHub
parent 119d5e72ef
commit 703b185982
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -554,7 +554,7 @@ func replaceRawPath(u *url.URL, rp string) {
q = fs[1]
}
if p[0] == '/' {
if p != "" && p[0] == '/' {
u.Path = p
} else {
u.Path += p
+13
View File
@@ -79,3 +79,16 @@ func TestControlURLParsing(t *testing.T) {
t.Error("URL normalization of", subject, "failed; expected", expected, "got", u.String())
}
}
func TestControlURLParsingQueryOnly(t *testing.T) {
rootURL := "http://192.168.243.1:80/igd.xml"
u, _ := url.Parse(rootURL)
subject := "?control=WANCommonIFC1"
expected := "http://192.168.243.1:80/igd.xml?control=WANCommonIFC1"
replaceRawPath(u, subject)
if u.String() != expected {
t.Error("URL normalization of", subject, "failed; expected", expected, "got", u.String())
}
}