protocol/rtsp: in ReadResponse response length check comes before protocol check

This commit is contained in:
Saxon 2019-04-29 13:19:32 +09:30
parent ba7e768269
commit eac5652f1b
1 changed files with 6 additions and 2 deletions

View File

@ -132,8 +132,12 @@ func ReadResponse(r io.Reader) (*Response, error) {
} }
s := scanner.Text() s := scanner.Text()
if s[:5] != "RTSP/" || len(s) < minResponse { if len(s) < minResponse {
return nil, errors.New("response not valid") return nil, errors.New("response length too small")
}
if s[:5] != "RTSP/" {
return nil, errors.New("invalid response")
} }
resp.Proto = "RTSP" resp.Proto = "RTSP"