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

Casts should be checked #447

Open
benrubson opened this issue Nov 2, 2017 · 0 comments
Open

Casts should be checked #447

benrubson opened this issue Nov 2, 2017 · 0 comments
Labels
Milestone

Comments

@benrubson
Copy link
Contributor

benrubson commented Nov 2, 2017

Here is a bug report in order to think about types' check.

Going through the code, there are many places where size_t / ssize_t / off_t / int... are wrongly used and may lead to some overflows...
Some implicit and explicit casts between size_t / ssize_t / int which are also sometimes wrongly done, leading to some limits (even if they are high) which could be overflowed.

For example, read and write operations deal with as much as dataLen (size_t), and return ssize_t, which does not seem to be absolutely correct.
Another example where an int is used to go through the number of blocks (should be an off_t) :
https://github.com/vgough/encfs/blob/v1.9.2/encfs/encfsctl.cpp#L388

This is a fiddly check to do then.

As indicated in #446, I think we should keep :

  • size_t for dataLen, as in read(2) / write(2) ;
  • ssize_t as read & write return type, as in read(2) / write(2) ;
  • off_t for sizes and offsets, as in stat(2).
@benrubson benrubson changed the title Implicit casts should be checked Casts should be checked Nov 3, 2017
@benrubson benrubson added the bug label Nov 15, 2017
@benrubson benrubson added this to the 1.9.4 milestone Nov 18, 2017
@benrubson benrubson modified the milestones: 1.9.5, 1.9.6 Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant