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

Ensure args is an array #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

baptistejamin
Copy link

Id packet.id is null and packet.data is not an array you can expect this error:

CreateListFromArrayLike called on non-object

This commit is fixing this.

@hden
Copy link
Owner

hden commented Jun 10, 2017

Socket.io itself handles event packets in a similar way https://github.com/socketio/socket.io/blob/2b216902e121ac2205444019b6d9316654809b29/lib/socket.js#L351-L359

What's the packet.type when the error is thrown?

@baptistejamin
Copy link
Author

Yes, Socket IO is using in a similar way, but socket IO is not using apply.

Apply requires an array. Socket IO is not using apply, that's why it's not crashing socket IO.

@hden
Copy link
Owner

hden commented Jun 12, 2017

Can you provide a minimal code sample that reproduces the error?

var args = packet.data || []
var args = [];

if (packet.data && packet.data.constructor === Array) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For those packet.data which is not an Array, what are them? Any reason that we should ignore them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A socket IO payload should be like [ 'my_event', my_data ]

There is no reason to catch non-array payloads. These are not valid at all.

You can just send raw data over a websocket and crash an entire server.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, random raw data through the websocket should not get through the parser at all. Maybe what we are dealing with is an error packet? In this case, we might actually want to catch that.

@hden hden mentioned this pull request Jun 12, 2017
2 tasks
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