From eac5652f1bb29b3ca9271ed3fcd46cf8a5f47280 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 29 Apr 2019 13:19:32 +0930 Subject: [PATCH] protocol/rtsp: in ReadResponse response length check comes before protocol check --- protocol/rtsp/rtsp.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/protocol/rtsp/rtsp.go b/protocol/rtsp/rtsp.go index 22d84236..fb9130bc 100644 --- a/protocol/rtsp/rtsp.go +++ b/protocol/rtsp/rtsp.go @@ -132,8 +132,12 @@ func ReadResponse(r io.Reader) (*Response, error) { } s := scanner.Text() - if s[:5] != "RTSP/" || len(s) < minResponse { - return nil, errors.New("response not valid") + if len(s) < minResponse { + return nil, errors.New("response length too small") + } + + if s[:5] != "RTSP/" { + return nil, errors.New("invalid response") } resp.Proto = "RTSP"