From 10664f40c48e552103d969ae4bdf375e95944b64 Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Mon, 21 Oct 2024 16:59:35 +0200 Subject: [PATCH] Added a nil check for resp.GetError() in the EOS gRPC client. This fixes a nil pointer dereference in the RollbackToVersion method (#4896) Co-authored-by: Jesse Geens --- changelog/unreleased/restorefileversion-nilptr.md | 3 +++ pkg/eosclient/eosgrpc/eosgrpc.go | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/restorefileversion-nilptr.md diff --git a/changelog/unreleased/restorefileversion-nilptr.md b/changelog/unreleased/restorefileversion-nilptr.md new file mode 100644 index 0000000000..970380f3bd --- /dev/null +++ b/changelog/unreleased/restorefileversion-nilptr.md @@ -0,0 +1,3 @@ +Bugfix: fix nilpointer error in RollbackToVersion + +https://github.com/cs3org/reva/pull/4896 diff --git a/pkg/eosclient/eosgrpc/eosgrpc.go b/pkg/eosclient/eosgrpc/eosgrpc.go index 8a86c1b5cd..f171511a17 100644 --- a/pkg/eosclient/eosgrpc/eosgrpc.go +++ b/pkg/eosclient/eosgrpc/eosgrpc.go @@ -1544,8 +1544,9 @@ func (c *Client) RollbackToVersion(ctx context.Context, auth eosclient.Authoriza return errtypes.InternalError(fmt.Sprintf("nil response for uid: '%s' ", auth.Role.UID)) } - log.Info().Str("func", "RollbackToVersion").Int64("errcode", resp.GetError().Code).Str("errmsg", resp.GetError().Msg).Msg("grpc response") - + if resp.GetError() != nil { + log.Info().Str("func", "RollbackToVersion").Int64("errcode", resp.GetError().Code).Str("errmsg", resp.GetError().Msg).Msg("grpc response") + } return err }