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

Usage of size_t for file addresses by LibGens #2

Open
NotKit opened this issue Aug 23, 2015 · 0 comments
Open

Usage of size_t for file addresses by LibGens #2

NotKit opened this issue Aug 23, 2015 · 0 comments

Comments

@NotKit
Copy link
Contributor

NotKit commented Aug 23, 2015

LibGens and namely LibGens::File class use size_t type for reading/writing addresses stored in files.
size_t is unsigned int on 32-bit systems, but for 64-bit ones it is unsigned long int (8 bytes). This breaks code portability.
readInt32A and readInt32BEA, as well as corresponding write functions, are supposed to always read 32-bit value even on 64-bit systems for file formats compatibility. There are different ways to approach this, and I'm not sure what would be the correct one.

  1. Replace size_t by unsigned int where needed. This should be save as long as it's used for file offsets, and not for memory pointers, but might require a lot of code edits.
  2. Introduce a custom typedef for unsigned int. The rest is the same as first.
  3. Modify read functions to ensure they always read 4 bytes and then properly put them into 8 bytes size_t variables, as well as do the opposite to write. The easiest, but seems like a hack to me.
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

1 participant