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:
Nick Craig-Wood
2026-07-30 15:22:03 +01:00
parent c1ff08a627
commit 862ed2b7ac
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -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