Skip to content

Commit

Permalink
fix panic in sspReferenceIsChildOf
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Oct 26, 2023
1 parent b57d70a commit 74f64c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Bugfix: Prevent panic when trying to move a non-existent file

We fixed a panic when the user tried to move a file which does not exist.

https://github.com/cs3org/reva/pull/4290
https://github.com/cs3org/reva/pull/4283
18 changes: 11 additions & 7 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,14 +339,14 @@ func (s *svc) sspReferenceIsChildOf(ctx context.Context, selector pool.Selectabl
if err != nil {
return false, err
}
if parentStatRes.Status.Code != rpc.Code_CODE_OK {
return false, errtypes.NewErrtypeFromStatus(parentStatRes.Status)
if parentStatRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
return false, errtypes.NewErrtypeFromStatus(parentStatRes.GetStatus())
}
parentAuthCtx, err := authContextForUser(client, parentStatRes.Info.Owner, s.c.MachineAuthAPIKey)
parentAuthCtx, err := authContextForUser(client, parentStatRes.GetInfo().GetOwner(), s.c.MachineAuthAPIKey)
if err != nil {
return false, err
}
parentPathRes, err := client.GetPath(parentAuthCtx, &provider.GetPathRequest{ResourceId: parentStatRes.Info.Id})
parentPathRes, err := client.GetPath(parentAuthCtx, &provider.GetPathRequest{ResourceId: parentStatRes.GetInfo().GetId()})
if err != nil {
return false, err
}
Expand All @@ -355,7 +355,7 @@ func (s *svc) sspReferenceIsChildOf(ctx context.Context, selector pool.Selectabl
if err != nil {
return false, err
}
if childStatRes.Status.Code == rpc.Code_CODE_NOT_FOUND && utils.IsRelativeReference(child) && child.Path != "." {
if childStatRes.GetStatus().GetCode() == rpc.Code_CODE_NOT_FOUND && utils.IsRelativeReference(child) && child.Path != "." {
childParentRef := &provider.Reference{
ResourceId: child.ResourceId,
Path: utils.MakeRelativePath(path.Dir(child.Path)),
Expand All @@ -365,11 +365,15 @@ func (s *svc) sspReferenceIsChildOf(ctx context.Context, selector pool.Selectabl
return false, err
}
}
childAuthCtx, err := authContextForUser(client, childStatRes.Info.Owner, s.c.MachineAuthAPIKey)
if childStatRes.GetStatus().GetCode() != rpc.Code_CODE_OK {
return false, errtypes.NewErrtypeFromStatus(parentStatRes.Status)
}
// TODO: this should use service accounts https://github.com/owncloud/ocis/issues/7597
childAuthCtx, err := authContextForUser(client, childStatRes.GetInfo().GetOwner(), s.c.MachineAuthAPIKey)
if err != nil {
return false, err
}
childPathRes, err := client.GetPath(childAuthCtx, &provider.GetPathRequest{ResourceId: childStatRes.Info.Id})
childPathRes, err := client.GetPath(childAuthCtx, &provider.GetPathRequest{ResourceId: childStatRes.GetInfo().GetId()})
if err != nil {
return false, err
}
Expand Down

0 comments on commit 74f64c4

Please sign in to comment.