increase maximum length of urls, header keys and values

This commit is contained in:
aler9
2020-03-13 14:18:35 +01:00
parent 6ca36620dc
commit 13b7bffbba
2 changed files with 12 additions and 6 deletions

View File

@@ -8,8 +8,8 @@ import (
const ( const (
_MAX_HEADER_COUNT = 255 _MAX_HEADER_COUNT = 255
_MAX_HEADER_KEY_LENGTH = 255 _MAX_HEADER_KEY_LENGTH = 1024
_MAX_HEADER_VALUE_LENGTH = 255 _MAX_HEADER_VALUE_LENGTH = 1024
) )
// Header is a RTSP reader, present in both Requests and Responses. // Header is a RTSP reader, present in both Requests and Responses.

View File

@@ -5,6 +5,12 @@ import (
"fmt" "fmt"
) )
const (
_MAX_METHOD_LENGTH = 128
_MAX_PATH_LENGTH = 1024
_MAX_PROTOCOL_LENGTH = 128
)
// Request is a RTSP request. // Request is a RTSP request.
type Request struct { type Request struct {
Method string Method string
@@ -16,7 +22,7 @@ type Request struct {
func readRequest(br *bufio.Reader) (*Request, error) { func readRequest(br *bufio.Reader) (*Request, error) {
req := &Request{} req := &Request{}
byts, err := readBytesLimited(br, ' ', 255) byts, err := readBytesLimited(br, ' ', _MAX_METHOD_LENGTH)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -26,17 +32,17 @@ func readRequest(br *bufio.Reader) (*Request, error) {
return nil, fmt.Errorf("empty method") return nil, fmt.Errorf("empty method")
} }
byts, err = readBytesLimited(br, ' ', 255) byts, err = readBytesLimited(br, ' ', _MAX_PATH_LENGTH)
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Url = string(byts[:len(byts)-1]) req.Url = string(byts[:len(byts)-1])
if len(req.Url) == 0 { if len(req.Url) == 0 {
return nil, fmt.Errorf("empty path") return nil, fmt.Errorf("empty url")
} }
byts, err = readBytesLimited(br, '\r', 255) byts, err = readBytesLimited(br, '\r', _MAX_PROTOCOL_LENGTH)
if err != nil { if err != nil {
return nil, err return nil, err
} }