From 339fb74cbcd2e39295e40484c013100ad404fbdf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 16 Oct 2019 03:28:02 +0200 Subject: [PATCH] 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 --- daemon/info_unix.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/info_unix.go b/daemon/info_unix.go index f34a03307c..06a67271b5 100644 --- a/daemon/info_unix.go +++ b/daemon/info_unix.go @@ -72,7 +72,9 @@ func (daemon *Daemon) fillPlatformInfo(v *types.Info, sysInfo *sysinfo.SysInfo) v.InitCommit.ID = "N/A" } else { 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 { logrus.Warnf("failed to retrieve %s version: %s", defaultInitBinary, err)