kata-runtime: use filepath.Join() to compose file path

Use filepath.Join() will be safer than format string directly.

Signed-off-by: bin <bin@hyper.sh>
This commit is contained in:
bin
2021-02-04 21:57:52 +08:00
parent f4ae9c8476
commit 10f1c30f3d
2 changed files with 3 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"strings"
"sync"
@@ -175,7 +176,7 @@ func (s *iostream) Read(data []byte) (n int, err error) {
}
func getConn(namespace, sandboxID string, port uint64) (net.Conn, error) {
socketAddr := fmt.Sprintf("/containerd-shim/%s/%s/shim-monitor.sock", namespace, sandboxID)
socketAddr := filepath.Join(string(filepath.Separator), "containerd-shim", namespace, sandboxID, "shim-monitor.sock")
client, err := kataMonitor.BuildUnixSocketClient(socketAddr, defaultTimeout)
if err != nil {
return nil, err