oracleobjectstorage: fix crash when downloading objects with unknown length - fixes #9694
Object.Open dereferenced the response's ContentLength pointer without checking it. The OCI SDK leaves ContentLength nil when the server replies without a Content-Length header or ContentRange which caused a nil pointer panic. Now the size is only updated when the response actually provides one, leaving the size from the object metadata in place otherwise. This also fixes the same potential problem in the newObject code.
This commit is contained in:
@@ -362,7 +362,11 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadClo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.bytes = *bytes
|
||||
if bytes != nil {
|
||||
o.bytes = *bytes
|
||||
} else {
|
||||
fs.Debugf(o, "Failed to find object length")
|
||||
}
|
||||
return resp.HTTPResponse().Body, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -516,7 +516,11 @@ func (f *Fs) newObjectWithInfo(ctx context.Context, remote string, info *objects
|
||||
o.md5 = md5
|
||||
}
|
||||
}
|
||||
o.bytes = *info.Size
|
||||
if info.Size != nil {
|
||||
o.bytes = *info.Size
|
||||
} else {
|
||||
fs.Debugf(o, "Failed to find object length")
|
||||
}
|
||||
o.storageTier = storageTierMap[strings.ToLower(string(info.StorageTier))]
|
||||
} else {
|
||||
err := o.readMetaData(ctx) // reads info and headers, returning an error
|
||||
|
||||
Reference in New Issue
Block a user