瀏覽代碼

RootIsShared() - Fix array out of bounds error

This happened for me on the last (empty) line, but better safe than sorry
so we make the check general.
Alexander Larsson 12 年之前
父節點
當前提交
d478a4bb54
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      utils.go

+ 1 - 1
utils.go

@@ -173,7 +173,7 @@ func RootIsShared() bool {
 	if data, err := ioutil.ReadFile("/proc/self/mountinfo"); err == nil {
 		for _, line := range strings.Split(string(data), "\n") {
 			cols := strings.Split(line, " ")
-			if cols[3] == "/" && cols[4] == "/" {
+			if len(cols) >= 6 && cols[3] == "/" && cols[4] == "/" {
 				return strings.HasPrefix(cols[6], "shared")
 			}
 		}