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

Fix PointCloud2 buffers #244

Merged
merged 2 commits into from
Jan 16, 2019

Conversation

mvollrath
Copy link
Contributor

@mvollrath mvollrath commented Jan 6, 2019

Move the decoding buffer out of Points, since it's only needed during base64 decode. This prevents unnecessary buffer dereference during decoding.

This also prevents certain errors when the point cloud data is malformed by slicing the original buffer during binary decoding.

Move the decoding buffer out of Points, since it's only needed during base64 decode.

if (msg.data.buffer) {
this.points.buffer.set(msg.data);
this.buffer = msg.data.slice(0, Math.min(msg.data.byteLength, bufSz));
n = msg.height*msg.width / pointRatio;
Copy link

Choose a reason for hiding this comment

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

Note that n doesn't necessarily match the proper limit to iterate this.points.positions.array below (see here), as height and width come from the message but you might be clipping the buffer to bufSz.
In other words, you may get out of range of points.positions.array when you iterate up to n like this.

One option could be making n = Math.min(msg.height*msg.width / pointRatio, this.points.positions.array.length / 3); (the else case below this one also needs to be reviewed).

src/sensors/PointCloud2.js Outdated Show resolved Hide resolved
Thanks @jubeira for this change.

Co-Authored-By: mvollrath <matt@endpoint.com>
@jihoonl
Copy link
Member

jihoonl commented Jan 16, 2019

Hi @mvollrath, I put you as a maintainer as you seems working hard on rosbridge, and roslibs. Feel free to merge the patches in. 👍

@mvollrath mvollrath merged commit 1d2e041 into RobotWebTools:develop Jan 16, 2019
@mvollrath
Copy link
Contributor Author

Thank you!

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