Skip to content

fix: Prevent crash in packet::parse by validating std::stoi input #440

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

Merged
merged 1 commit into from
May 13, 2025

Conversation

JeHeeYu
Copy link
Contributor

@JeHeeYu JeHeeYu commented May 10, 2025

This PR addresses an issue where std::stoi would throw an std::invalid_argument exception when the Socket.IO packet payload contained non-numeric characters in the expected pack ID field.

Changes include:

  • Added validation to check whether the substring is numeric before calling std::stoi.
  • Added logging for malformed packet segments to aid debugging.
  • Ensures stability when binary or malformed packets are received.

This change prevents application crashes caused by invalid Socket.IO payloads, particularly under Linux, where behavior previously diverged from Windows.

@JeHeeYu JeHeeYu changed the title Prevent crash in packet::parse by validating std::stoi input Fix: Prevent crash in packet::parse by validating std::stoi input May 10, 2025
@JeHeeYu JeHeeYu changed the title Fix: Prevent crash in packet::parse by validating std::stoi input fix: Prevent crash in packet::parse by validating std::stoi input May 10, 2025
@jmigual jmigual merged commit 6a3bd6a into socketio:master May 13, 2025
1 of 3 checks passed
@jmigual
Copy link
Collaborator

jmigual commented May 13, 2025

Thanks for your work!

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.

2 participants