[php-fpm] Fix possible "index out of range" (#8461)

This commit is contained in:
Paweł Żak 2020-11-23 23:21:36 +01:00 committed by GitHub
parent 8b30bb9534
commit 832925d9c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 12 deletions

View File

@ -7,7 +7,6 @@ import (
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"sync"
@ -301,25 +300,18 @@ func globUnixSocket(url string) ([]string, error) {
}
paths := glob.Match()
if len(paths) == 0 {
if _, err := os.Stat(paths[0]); err != nil {
if os.IsNotExist(err) {
return nil, fmt.Errorf("Socket doesn't exist '%s': %s", pattern, err)
}
return nil, err
}
return nil, nil
return nil, fmt.Errorf("socket doesn't exist %q: %v", pattern, err)
}
addrs := make([]string, 0, len(paths))
addresses := make([]string, 0, len(paths))
for _, path := range paths {
if status != "" {
path = path + ":" + status
}
addrs = append(addrs, path)
addresses = append(addresses, path)
}
return addrs, nil
return addresses, nil
}
func unixSocketPaths(addr string) (string, string) {