Fix uses of "int" where "int64" should be used instead
Some structures use int for sizes and UNIX timestamps. On some platforms, int is 32 bits, so this can lead to the year 2038 issues and overflows when dealing with large containers or layers. Consistently use int64 to store sizes and UNIX timestamps in api/types/types.go. Update related to code accordingly (i.e. strconv.FormatInt instead of strconv.Itoa). Use int64 in progressreader package to avoid integer overflow when dealing with large quantities. Update related code accordingly. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>master
							parent
							
								
									56efe43c95
								
							
						
					
					
						commit
						cfb0b7aa77
					
				| 
						 | 
				
			
			@ -185,7 +185,7 @@ func TestGetRemoteImageJSON(t *testing.T) {
 | 
			
		|||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
	assertEqual(t, size, 154, "Expected size 154")
 | 
			
		||||
	assertEqual(t, size, int64(154), "Expected size 154")
 | 
			
		||||
	if len(json) <= 0 {
 | 
			
		||||
		t.Fatal("Expected non-empty json")
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -240,7 +240,7 @@ func (r *Session) LookupRemoteImage(imgID, registry string) error {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
// GetRemoteImageJSON retrieves an image's JSON metadata from the registry.
 | 
			
		||||
func (r *Session) GetRemoteImageJSON(imgID, registry string) ([]byte, int, error) {
 | 
			
		||||
func (r *Session) GetRemoteImageJSON(imgID, registry string) ([]byte, int64, error) {
 | 
			
		||||
	res, err := r.client.Get(registry + "images/" + imgID + "/json")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, -1, fmt.Errorf("Failed to download json: %s", err)
 | 
			
		||||
| 
						 | 
				
			
			@ -250,9 +250,9 @@ func (r *Session) GetRemoteImageJSON(imgID, registry string) ([]byte, int, error
 | 
			
		|||
		return nil, -1, httputils.NewHTTPRequestError(fmt.Sprintf("HTTP code %d", res.StatusCode), res)
 | 
			
		||||
	}
 | 
			
		||||
	// if the size header is not present, then set it to '-1'
 | 
			
		||||
	imageSize := -1
 | 
			
		||||
	imageSize := int64(-1)
 | 
			
		||||
	if hdr := res.Header.Get("X-Docker-Size"); hdr != "" {
 | 
			
		||||
		imageSize, err = strconv.Atoi(hdr)
 | 
			
		||||
		imageSize, err = strconv.ParseInt(hdr, 10, 64)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return nil, -1, err
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue