swarm/api/http: server handler: check protocol substring length to fix slice out of bounds crash

This commit is contained in:
zelig 2016-06-24 14:48:09 +02:00
parent 2b1c950193
commit 38184bf18d

View file

@ -86,8 +86,10 @@ func handler(w http.ResponseWriter, r *http.Request, a *api.Api) {
return
}
}
raw = proto[1:5] == "bzzr"
nameresolver = proto[1:5] != "bzzi"
if len(proto) > 4 {
raw = proto[1:5] == "bzzr"
nameresolver = proto[1:5] != "bzzi"
}
glog.V(logger.Debug).Infof(
"[BZZ] Swarm: %s request over protocol %s '%s' received.",