webdav: tus: fix potential nil pointer crash GHSA-3x6r-wxxg-53vv

This commit is contained in:
Nick Craig-Wood
2026-07-31 13:21:59 +01:00
parent 52cf74dc59
commit 5871d98c36
+12 -8
View File
@@ -44,14 +44,18 @@ func (o *Object) updateViaTus(ctx context.Context, in io.Reader, contentType str
func (f *Fs) getTusLocationOrRetry(ctx context.Context, resp *http.Response, err error) (bool, string, error) {
switch resp.StatusCode {
case 201:
location := resp.Header.Get("Location")
return false, location, nil
case 412:
return false, "", ErrVersionMismatch
case 413:
return false, "", ErrLargeUpload
// resp is nil if the HTTP transaction failed before a response
// was received, eg on connection refused or reset
if resp != nil {
switch resp.StatusCode {
case 201:
location := resp.Header.Get("Location")
return false, location, nil
case 412:
return false, "", ErrVersionMismatch
case 413:
return false, "", ErrLargeUpload
}
}
retry, err := f.shouldRetry(ctx, resp, err)