Browse Source

distribution: registry: do not access the errors slice if it's empty

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
Antonio Murdaca 9 years ago
parent
commit
0186f4d422
2 changed files with 5 additions and 2 deletions
  1. 2 1
      CHANGELOG.md
  2. 3 1
      distribution/registry.go

+ 2 - 1
CHANGELOG.md

@@ -16,7 +16,8 @@ be found.
 
 
 ### Distribution
 ### Distribution
 
 
-- Fix a crash when pushing multiple images sharing the same layers to the same repository in parallel  [#20831](https://github.com/docker/docker/pull/20831)
+- Fix a crash when pushing multiple images sharing the same layers to the same repository in parallel [#20831](https://github.com/docker/docker/pull/20831)
+- Fix a panic when pushing images to a registry which uses a misconfigured token service [#21030](https://github.com/docker/docker/pull/21030)
 
 
 ### Plugin system
 ### Plugin system
 
 

+ 3 - 1
distribution/registry.go

@@ -140,7 +140,9 @@ func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[s
 func retryOnError(err error) error {
 func retryOnError(err error) error {
 	switch v := err.(type) {
 	switch v := err.(type) {
 	case errcode.Errors:
 	case errcode.Errors:
-		return retryOnError(v[0])
+		if len(v) != 0 {
+			return retryOnError(v[0])
+		}
 	case errcode.Error:
 	case errcode.Error:
 		switch v.Code {
 		switch v.Code {
 		case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeUnsupported, errcode.ErrorCodeDenied:
 		case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeUnsupported, errcode.ErrorCodeDenied: