librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

out of bound access in rs2_project_color_pixel_to_depth_pixel

Open wsmlby opened this issue 1 year ago • 5 comments

https://github.com/IntelRealSense/librealsense/blob/e1688cc318457f7dd57abcdbedd3398062db3009/src/rs.cpp#L4120

this doesn't seems to assume coordinates are 0-indexed and allow y = height which can cause an out of bound access and crash.

wsmlby avatar Aug 28 '24 23:08 wsmlby

Hi @wsmlby An out of bounds access error is one that does not usually occur. If you are using C++, do you have any problems if you test the script at https://github.com/IntelRealSense/librealsense/issues/2982 which uses rs2_project_color_pixel_to_depth_pixel please?

MartyG-RealSense avatar Aug 29 '24 08:08 MartyG-RealSense

I mean it is pretty simple if in any case the passed in value get mapped to a p[1]= height here, it will cause a out of bounds access. We are seeing this in production.

Do you want me to provide a PR to fix this? Just set it to height - 1e-10 will work.

wsmlby avatar Aug 29 '24 08:08 wsmlby

This is not an issue that is currently being reported by other RealSense users, but of course this does not mean that it is not happening in your particular case. You are very welcome to submit a PR containing your fix.

MartyG-RealSense avatar Aug 29 '24 08:08 MartyG-RealSense

added a PR. please take a look.

we are currently working around this by allocate one more line for the depth buffer but this should not be needed.

wsmlby avatar Aug 29 '24 21:08 wsmlby

Thanks so much @wsmlby for the PR at https://github.com/IntelRealSense/librealsense/pull/13307

I have added an Enhancement label to this issue to signify that it shoukd be kept open whilst your PR is active. Thanks again!

MartyG-RealSense avatar Aug 30 '24 07:08 MartyG-RealSense