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

Kill R_NOTNULL #11553

Closed
radare opened this issue Sep 17, 2018 · 2 comments
Closed

Kill R_NOTNULL #11553

radare opened this issue Sep 17, 2018 · 2 comments

Comments

@radare
Copy link
Collaborator

radare commented Sep 17, 2018

This is (void*)(size_t)-1UL, which is a bad idea and shouldnt be used at all

@davidpolverari
Copy link
Contributor

Well, as I didn't understand before what this issue was about, I analyzed the places where R_NOTNULL is used. This is what I saw:

  • There are different definitions of static void * load_bytes(RBinFile *bf, const ut8 *buf, ut64 sz, ut64 loadaddr, Sdb *sdb), one in each file that deals with a different bin file.

  • R_NOTNULL is used only as a return value to some of those load_bytes definitions.

  • In those cases, that function only calls static bool check_bytes(const ut8 *buf, ut64 length), which, by its turn, only returns a bool, and doesn't use all the parameters that were passed to load_bytes.

  • Furthermore, it doesn't make sense to return a pointer, even more a constant one, in those cases, if they are totally unrelated with the results of check_bytes.

So the question is: in those cases, what should load_bytes return? A NULL? Any other pointer will be completely arbitrary and, if used somewhere else, could lead to bad results.

@radare
Copy link
Collaborator Author

radare commented Sep 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Refactorings
  
DONE
Development

No branches or pull requests

2 participants