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

Invalid pointer dereference in igtlNDArrayMessage.h #120

Closed
mikhirev opened this issue Feb 22, 2017 · 6 comments
Closed

Invalid pointer dereference in igtlNDArrayMessage.h #120

mikhirev opened this issue Feb 22, 2017 · 6 comments
Assignees

Comments

@mikhirev
Copy link

mikhirev commented Feb 22, 2017

Hi!

This issue is related to Fedora FTBFS bug that is also reproducible with OpenIGTLink 2.0 release. When using gcc 7, compilation fails with the following error:

In file included from /builddir/build/BUILD/OpenIGTLink-ccb24383e490ea1ddc07dd2d854e0d08efe80abc/Source/igtlNDArrayMessage.cxx:15:0:
/builddir/build/BUILD/OpenIGTLink-ccb24383e490ea1ddc07dd2d854e0d08efe80abc/Source/igtlNDArrayMessage.h: In member function 'int igtl::Array<T>::SetValue(igtl::ArrayBase::IndexType, T)':
/builddir/build/BUILD/OpenIGTLink-ccb24383e490ea1ddc07dd2d854e0d08efe80abc/Source/igtlNDArrayMessage.h:94:62: error: 'void*' is not a pointer-to-object type
       * (T *) this->m_ByteArray[Get1DIndex(index) * sizeof(T)] = value;
                                                              ^
/builddir/build/BUILD/OpenIGTLink-ccb24383e490ea1ddc07dd2d854e0d08efe80abc/Source/igtlNDArrayMessage.h: In member function 'int igtl::Array<T>::GetValue(igtl::ArrayBase::IndexType, T&)':
/builddir/build/BUILD/OpenIGTLink-ccb24383e490ea1ddc07dd2d854e0d08efe80abc/Source/igtlNDArrayMessage.h:105:70: error: 'void*' is not a pointer-to-object type
       value = * (T *) this->m_ByteArray[Get1DIndex(index) * sizeof(T)];
                                                                      ^

m_ByteArray is void *, so it seems that there's a superfluous dereference here.

@mikhirev
Copy link
Author

BTW igtl::Array<T>::GetValue() and igtl::Array<T>::SetValue() are unusable anyway. They cannot be instantiated because igtl::ArrayBase::m_ByteArray is private.

@tokjun
Copy link
Contributor

tokjun commented Feb 24, 2017

Thanks for reporting the issue. We will work on this soon.

@leochan2009
Copy link
Contributor

@mikhirev , Thanks for your report.
The GCC 7 is not released yet, there seems to be huge number of improvements.
i will make a local build of GCC 7 and make sure that OpenIGTLink is compatible with it.

@leochan2009 leochan2009 self-assigned this Feb 25, 2017
@mikhirev
Copy link
Author

@leochan2009, I think that building GCC 7 is not required. You may try to write a simple unit test for igtl::Array<T>::GetValue() and igtl::Array<T>::SetValue() and see that they are broken. That's what I did, and it failed to compile with GCC 5.

I'm going to remove these methods in Fedora package.

@leochan2009
Copy link
Contributor

@mikhirev
Thanks a lot. Now I see the point. It is definitive a bug, and was not detected by compiler previously.
Now the GCC-7 is able to detect the bug during the build.

@leochan2009
Copy link
Contributor

The pointer deference bug should be fixed now

wonjin added a commit to wonjin/OpenIGTLink that referenced this issue Sep 13, 2018
SetValue & GetValue is fixed in igtlNDArrayMessage.h
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

No branches or pull requests

3 participants