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.
Upstream-commit: 7d566b4f761e8942cf9679e96774b320b8496b2f
Component: engine
This commit is contained in:
Alexander Larsson
2013-09-13 11:08:59 +02:00
committed by Tianon Gravi
parent 74b00e51f4
commit ff5de9f609

View File

@ -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")
}
}