-
Notifications
You must be signed in to change notification settings - Fork 608
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
cv_bridge::toCvCopy() segfaults on some inputs #20
Comments
ok. With 1) , you can only check that data is not 0. Otherwise, you could have a valid pointer for an mount of data, then change width for example, and get a valid pointer with an invalid description. Therefore 1) can never be perfect and I'd rather not create a false feeling of safety. |
ok, done, thx. I completed the sentence: |
Are you sure that 1) is not possible? As for 2), the new documentation is still misleading, as it still seems to indicate that an exception is the worst possible outcome. On the contrary, these functions can cause your whole program to crash irrecoverably! The following would be better: You should always wrap your calls to toCvCopy() / toCvShared() to catch conversion errors. Moreover, you should be careful to only call these functions with well-formed input, as they may crash your program or corrupt memory if given ill-formed inputs, e.g. inputs whose dimensions do not match the length of their data. |
Right on both, will fix asap. |
I just took another look at your fix: bb3b694 I'm not so sure that it is correct to throw an error on
Therefore, the requirement that Perhaps you meant instead to require that |
yeah, obviously, why the hell did I do that ! Anyway, fixed and improved in ee10a9d |
Looks good to me. |
ok, re-releasing then ! |
The following program crashes with a segmentation fault.
Note that line 339 of cv_bridge.cpp constructs a matrix like this:
This call is unsafe if
source.data
is empty, or ifsource.height
,source.width
, andsource.step
do not accurately describesource.data
.Therefore, either:
toCvCopy()
should validate thatsource
is well-formed before calling this constructor, ortoCvCopy()
on an inconsistentsensor_msgs/Image
message.Note, furthermore, that
toCvShare()
appears to suffer from a similar problem.The text was updated successfully, but these errors were encountered: