Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

acd: Fix nil pointer deref - fixes #916

Nick Craig-Wood05798672c878
diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go
index 95cab7746..5190aa3dc 100644
--- a/amazonclouddrive/amazonclouddrive.go
+++ b/amazonclouddrive/amazonclouddrive.go
@@ -819,7 +819,7 @@ func (o *Object) Hash(t fs.HashType) (string, error) {
if t != fs.HashMD5 {
return "", fs.ErrHashUnsupported
}
- if o.info.ContentProperties.Md5 != nil {
+ if o.info.ContentProperties != nil && o.info.ContentProperties.Md5 != nil {
return *o.info.ContentProperties.Md5, nil
}
return "", nil
@@ -827,7 +827,10 @@ func (o *Object) Hash(t fs.HashType) (string, error) {
// Size returns the size of an object in bytes
func (o *Object) Size() int64 {
- return int64(*o.info.ContentProperties.Size)
+ if o.info.ContentProperties != nil && o.info.ContentProperties.Size != nil {
+ return int64(*o.info.ContentProperties.Size)
+ }
+ return 0 // Object is likely PENDING
}
// readMetaData gets the metadata if it hasn't already been fetched
@@ -1108,7 +1111,7 @@ OnConflict:
// MimeType of an Object if known, "" otherwise
func (o *Object) MimeType() string {
- if o.info.ContentProperties.ContentType != nil {
+ if o.info.ContentProperties != nil && o.info.ContentProperties.ContentType != nil {
return *o.info.ContentProperties.ContentType
}
return ""