Skip to content

Commit

Permalink
Fix the error handling and prevent the nil pointer error
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Aug 1, 2023
1 parent 8e6c45f commit 619af52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-error-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix the error handling

Fix the error handling and prevent the nil pointer error

https://github.com/owncloud/ocis/issues/6929
https://github.com/cs3org/reva/pull/4093
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,17 @@ func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, shar
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "missing resource information", fmt.Errorf("error getting resource information"))
return
}
if statRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
if statRes.GetStatus().GetCode() == rpc.Code_CODE_NOT_FOUND {
response.WriteOCSError(w, r, response.MetaNotFound.StatusCode, "update public share: resource not found", err)
return
}
response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc stat request failed for stat when updating a public share", err)
return
}

// empty permissions mean internal link here - NOT denial. Hence we need an extra check
if !sufficientPermissions(statRes.Info.PermissionSet, newPermissions, true) {
if !sufficientPermissions(statRes.GetInfo().GetPermissionSet(), newPermissions, true) {
response.WriteOCSError(w, r, http.StatusForbidden, "no share permission", nil)
return
}
Expand Down

0 comments on commit 619af52

Please sign in to comment.