mirror of https://bitbucket.org/ausocean/av.git
protocol/rtsp: doing length check in same if but before RTSP protocol check
This commit is contained in:
parent
64f6a3d814
commit
0a27395aea
|
@ -43,7 +43,7 @@ import (
|
|||
// Minimum response size to be considered valid in bytes.
|
||||
const minResponse = 12
|
||||
|
||||
var errSmallResponse = errors.New("response too small")
|
||||
var errInvalidResponse = errors.New("invalid response")
|
||||
|
||||
// Request describes an RTSP request.
|
||||
type Request struct {
|
||||
|
@ -132,12 +132,8 @@ func ReadResponse(r io.Reader) (*Response, error) {
|
|||
}
|
||||
s := scanner.Text()
|
||||
|
||||
if len(s) < minResponse {
|
||||
return nil, errSmallResponse
|
||||
}
|
||||
|
||||
if s[:5] != "RTSP/" {
|
||||
return nil, errors.New("invalid response")
|
||||
if len(s) < minResponse || s[:5] != "RTSP/" {
|
||||
return nil, errInvalidResponse
|
||||
}
|
||||
resp.Proto = "RTSP"
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ func TestMethods(t *testing.T) {
|
|||
|
||||
for i, test := range tests {
|
||||
_, err = test.method(clt)
|
||||
if err != nil && err != io.EOF && err != errSmallResponse {
|
||||
if err != nil && err != io.EOF && err != errInvalidResponse {
|
||||
clientErr <- errors.New(fmt.Sprintf("error request for: %v err: %v", i, err))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue