Skip to content

Commit

Permalink
GuidCheckerService: Verify PSP avatar GUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Dec 23, 2023
1 parent e268a34 commit af501a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions Refresh.GameServer/Endpoints/Game/UserEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,27 @@ public SerializedUserList GetMultipleUsers(RequestContext context, GameDatabaseC

if (data.IconHash != null)
{
if (!data.IconHash.StartsWith('g') && !dataStore.ExistsInStore(data.IconHash))
//If the icon is a GUID
if (data.IconHash.StartsWith('g'))
{
database.AddErrorNotification("Profile update failed", "Your avatar failed to update because the asset was missing on the server.", user);
return null;
//Parse out the GUID
long guid = long.Parse(data.IconHash.AsSpan()[1..]);

//If its not a valid GUID, block the request
if(data.IconHash.StartsWith('g') && !guidChecker.IsTextureGuid(token.TokenGame, guid))
{
database.AddErrorNotification("Profile update failed", "Your avatar failed to update because the asset was an invalid GUID.", user);
return null;
}
}

if(data.IconHash.StartsWith('g') && !guidChecker.IsTextureGuid(token.TokenGame, long.Parse(data.IconHash.AsSpan()[1..])))
else
{
database.AddErrorNotification("Profile update failed", "Your avatar failed to update because the asset was an invalid GUID.", user);
return null;
//If the asset does not exist on the server, block the request
if (!dataStore.ExistsInStore(data.IconHash))
{
database.AddErrorNotification("Profile update failed", "Your avatar failed to update because the asset was missing on the server.", user);
return null;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Refresh.GameServer/Services/GuidCheckerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public bool IsTextureGuid(TokenGame game, long guid)
TokenGame.LittleBigPlanet2 => this._validMainlineTextureGuids.TryGetValue(guid, out _),
TokenGame.LittleBigPlanet3 => this._validMainlineTextureGuids.TryGetValue(guid, out _),
TokenGame.LittleBigPlanetVita => this._validVitaTextureGuids.TryGetValue(guid, out _),
TokenGame.LittleBigPlanetPSP => true,
TokenGame.LittleBigPlanetPSP => guid is >= 0 and <= 63, //PSP avatar GUIDs can be g0 - g63
_ => throw new ArgumentOutOfRangeException(nameof(game), game, null),
};
}
Expand Down

0 comments on commit af501a9

Please sign in to comment.