Make sure Upload-Offset in PATCH request is greater than 0
This commit is contained in:
parent
1f6aac2a49
commit
e451dc5f65
14
handler.go
14
handler.go
|
@ -284,6 +284,13 @@ func (handler *Handler) patchFile(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
//Check for presence of a valid Upload-Offset Header
|
||||
offset, err := strconv.ParseInt(r.Header.Get("Upload-Offset"), 10, 64)
|
||||
if err != nil || offset < 0 {
|
||||
handler.sendError(w, r, ErrInvalidOffset)
|
||||
return
|
||||
}
|
||||
|
||||
id := r.URL.Query().Get(":id")
|
||||
|
||||
// Ensure file is not locked
|
||||
|
@ -312,13 +319,6 @@ func (handler *Handler) patchFile(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// Ensure the offsets match
|
||||
offset, err := strconv.ParseInt(r.Header.Get("Upload-Offset"), 10, 64)
|
||||
if err != nil {
|
||||
handler.sendError(w, r, ErrInvalidOffset)
|
||||
return
|
||||
}
|
||||
|
||||
if offset != info.Offset {
|
||||
handler.sendError(w, r, ErrIllegalOffset)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue