mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-09 11:52:02 -08:00
check path name in configuration
This commit is contained in:
parent
1399543e90
commit
edb2c1f5cd
3 changed files with 20 additions and 3 deletions
|
|
@ -355,8 +355,9 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if strings.Index(path, "/") >= 0 {
|
||||
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("slashes in the path are not supported (%s)", path))
|
||||
err := checkPathName(path)
|
||||
if err != nil {
|
||||
c.writeResError(req, gortsplib.StatusBadRequest, fmt.Errorf("invalid path name: %s (%s)", err, path))
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +368,7 @@ func (c *client) handleRequest(req *gortsplib.Request) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
err := c.authenticate(confp.publishIpsParsed, confp.PublishUser, confp.PublishPass, req)
|
||||
err = c.authenticate(confp.publishIpsParsed, confp.PublishUser, confp.PublishPass, req)
|
||||
if err != nil {
|
||||
if err == errAuthCritical {
|
||||
return false
|
||||
|
|
|
|||
5
conf.go
5
conf.go
|
|
@ -180,6 +180,11 @@ func loadConf(fpath string, stdin io.Reader) (*conf, error) {
|
|||
confp = conf.Paths[name]
|
||||
}
|
||||
|
||||
err := checkPathName(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid path name: %s (%s)", err, name)
|
||||
}
|
||||
|
||||
if confp.Source == "" {
|
||||
confp.Source = "record"
|
||||
}
|
||||
|
|
|
|||
11
utils.go
11
utils.go
|
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
|
@ -161,3 +162,13 @@ func makeIpKey(ip net.IP) ipKey {
|
|||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
var rePathName = regexp.MustCompile("^[0-9a-zA-Z_-]+$")
|
||||
|
||||
func checkPathName(name string) error {
|
||||
if !rePathName.MatchString(name) {
|
||||
return fmt.Errorf("can contain only alfanumeric characters, underscore or minus")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue