Explorar o código

prevent panic if TINI_COMMIT isn't set during build

If TINI_COMMIT isn't set, .go-autogen sets an empty value
as the "expected" commit. Attempting to truncate the value
caused a panic in that situation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn %!s(int64=5) %!d(string=hai) anos
pai
achega
339fb74cbc
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      daemon/info_unix.go

+ 3 - 1
daemon/info_unix.go

@@ -72,7 +72,9 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo)
 			v.InitCommit.ID = "N/A"
 			v.InitCommit.ID = "N/A"
 		} else {
 		} else {
 			v.InitCommit.ID = commit
 			v.InitCommit.ID = commit
-			v.InitCommit.Expected = dockerversion.InitCommitID[0:len(commit)]
+			if len(dockerversion.InitCommitID) > len(commit) {
+				v.InitCommit.Expected = dockerversion.InitCommitID[0:len(commit)]
+			}
 		}
 		}
 	} else {
 	} else {
 		logrus.Warnf("failed to retrieve %s version: %s", defaultInitBinary, err)
 		logrus.Warnf("failed to retrieve %s version: %s", defaultInitBinary, err)