mirror of https://bitbucket.org/ausocean/av.git
protocol/rtsp: doing RTSP and response length check in same if
This commit is contained in:
parent
ba5a0d898c
commit
77e5d234de
|
@ -41,7 +41,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Minimum response size to be considered valid in bytes.
|
// Minimum response size to be considered valid in bytes.
|
||||||
const minResponse = 2
|
const minResponse = 12
|
||||||
|
|
||||||
var errSmallResponse = errors.New("response too small")
|
var errSmallResponse = errors.New("response too small")
|
||||||
|
|
||||||
|
@ -132,12 +132,8 @@ func ReadResponse(r io.Reader) (*Response, error) {
|
||||||
}
|
}
|
||||||
s := scanner.Text()
|
s := scanner.Text()
|
||||||
|
|
||||||
if len(s) < minResponse {
|
if s[:5] != "RTSP/" || len(s) < minResponse {
|
||||||
return nil, errSmallResponse
|
return nil, errors.New("response not valid")
|
||||||
}
|
|
||||||
|
|
||||||
if s[:5] != "RTSP/" {
|
|
||||||
return nil, errors.New("not a valid RTSP response")
|
|
||||||
}
|
}
|
||||||
resp.Proto = "RTSP"
|
resp.Proto = "RTSP"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue