Skip to content

Commit

Permalink
Fix nil pointer derefernce issues (#3379)
Browse files Browse the repository at this point in the history
Discovered while running
https://gitlab.futo.org/load-testing/matrix-goose.

Dendrite locks up and runs into `context cancelled`, so the error is not
`sql.ErrNoRows` nor "default" (and definitely shouldn't return that the
account exists in this case)
  • Loading branch information
S7evinK committed Jul 27, 2024
1 parent 795c4a9 commit affb697
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions roomserver/storage/postgres/user_room_keys_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")

resultMap := make(map[types.RoomNID]ed25519.PublicKey)
Expand Down
3 changes: 3 additions & 0 deletions roomserver/storage/sqlite3/user_room_keys_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func (s *userRoomKeysStatements) SelectAllPublicKeysForUser(ctx context.Context,
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
if err != nil {
return nil, err
}
defer internal.CloseAndLogIfError(ctx, rows, "SelectAllPublicKeysForUser: failed to close rows")

resultMap := make(map[types.RoomNID]ed25519.PublicKey)
Expand Down
3 changes: 2 additions & 1 deletion userapi/internal/user_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,11 +939,12 @@ func (a *UserInternalAPI) QueryAccountByPassword(ctx context.Context, req *api.Q
return nil
case bcrypt.ErrHashTooShort: // user exists, but probably a passwordless account
return nil
default:
case nil:
res.Exists = true
res.Account = acc
return nil
}
return err
}

func (a *UserInternalAPI) SetDisplayName(ctx context.Context, localpart string, serverName spec.ServerName, displayName string) (*authtypes.Profile, bool, error) {
Expand Down

0 comments on commit affb697

Please sign in to comment.