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

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

Nick Craig-Wood5871d98c3687
diff --git a/backend/webdav/tus.go b/backend/webdav/tus.go
index 3f6a843bb..77207bc3c 100644
--- a/backend/webdav/tus.go
+++ b/backend/webdav/tus.go
@@ -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)