Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t crash on unknown event data #771

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stefans256
Copy link

@stefans256 stefans256 commented Feb 19, 2023

Description

Fixing issue with unsafe reading of event.data['name']

Detected when integrating firebase auth. We get event data that falls through the checks in _registerEvents and does not follow the expected format.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@timbotimbo
Copy link
Collaborator

Looks good to me.

Might be safer to scope only the event parsing, to avoid catching something unrelated triggered by processEvents in the future.

UnityWebEvent? webEvent;
try {
  webEvent = UnityWebEvent(
    name: event.data['name'],
    data: event.data['data'],
  );
} catch (e) {
 ...
}

if(webEvent != null) {
  _processEvents(webEvent);
}

@Ahmadre Ahmadre requested review from Ahmadre and juicycleff January 1, 2024 02:05
@Ahmadre Ahmadre removed the request for review from juicycleff January 1, 2024 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants