webdav: tus: fix potential nil pointer crash GHSA-3x6r-wxxg-53vv
This commit is contained in:
+12
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user