mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not allow corrupted syslog-address
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
aef15ffc5d
commit
b7a6d14bdc
1 changed files with 27 additions and 25 deletions
|
@ -107,33 +107,35 @@ func (s *syslogger) Name() string {
|
|||
}
|
||||
|
||||
func parseAddress(address string) (string, string, error) {
|
||||
if urlutil.IsTransportURL(address) {
|
||||
url, err := url.Parse(address)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
// unix socket validation
|
||||
if url.Scheme == "unix" {
|
||||
if _, err := os.Stat(url.Path); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return url.Scheme, url.Path, nil
|
||||
}
|
||||
|
||||
// here we process tcp|udp
|
||||
host := url.Host
|
||||
if _, _, err := net.SplitHostPort(host); err != nil {
|
||||
if !strings.Contains(err.Error(), "missing port in address") {
|
||||
return "", "", err
|
||||
}
|
||||
host = host + ":514"
|
||||
}
|
||||
|
||||
return url.Scheme, host, nil
|
||||
if address == "" {
|
||||
return "", "", nil
|
||||
}
|
||||
if !urlutil.IsTransportURL(address) {
|
||||
return "", "", fmt.Errorf("syslog-address should be in form proto://address, got %v", address)
|
||||
}
|
||||
url, err := url.Parse(address)
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
return "", "", nil
|
||||
// unix socket validation
|
||||
if url.Scheme == "unix" {
|
||||
if _, err := os.Stat(url.Path); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
return url.Scheme, url.Path, nil
|
||||
}
|
||||
|
||||
// here we process tcp|udp
|
||||
host := url.Host
|
||||
if _, _, err := net.SplitHostPort(host); err != nil {
|
||||
if !strings.Contains(err.Error(), "missing port in address") {
|
||||
return "", "", err
|
||||
}
|
||||
host = host + ":514"
|
||||
}
|
||||
|
||||
return url.Scheme, host, nil
|
||||
}
|
||||
|
||||
// ValidateLogOpt looks for syslog specific log options
|
||||
|
|
Loading…
Reference in a new issue