From 38184bf18da60174b43b2b5e4ba032ef80a992dc Mon Sep 17 00:00:00 2001 From: zelig Date: Fri, 24 Jun 2016 14:48:09 +0200 Subject: [PATCH] swarm/api/http: server handler: check protocol substring length to fix slice out of bounds crash --- swarm/api/http/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index 945fc4f6e0..29945a9f77 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -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.",