Browse code

Add missing bounds in ContinueOnError

ContinueOnError assumes that something of type errcode.Errors contains
at least one error. This is generally true, but might not be true if the
remote registry returns an empty error body or invalid JSON. Add the
bounds check, and in the case where it fails, allow fallbacks to v1.

Fixes #18481

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

Aaron Lehmann authored on 2015/12/08 10:28:10
Showing 1 changed files
... ...
@@ -213,6 +213,9 @@ func (e ErrNoSupport) Error() string {
213 213
 func ContinueOnError(err error) bool {
214 214
 	switch v := err.(type) {
215 215
 	case errcode.Errors:
216
+		if len(v) == 0 {
217
+			return true
218
+		}
216 219
 		return ContinueOnError(v[0])
217 220
 	case ErrNoSupport:
218 221
 		return ContinueOnError(v.Err)