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

32-bit [non-]support #3

Open
DavidBuchanan314 opened this issue Feb 23, 2024 · 5 comments
Open

32-bit [non-]support #3

DavidBuchanan314 opened this issue Feb 23, 2024 · 5 comments

Comments

@DavidBuchanan314
Copy link
Owner

DavidBuchanan314 commented Feb 23, 2024

This code was written with 64-bit platforms in mind. If sizeof(size_t) == 4, bad things might happen (wrt. integer overflows related to the length of large buffers).

I should either make sure it works safely on 32-bit platforms (I suspect not!), or prevent it from building on 32-bit platforms.

@DavidBuchanan314
Copy link
Owner Author

I suppose a lot of old raspberry pis are 32-bit still (or at least, 32-bit userland), and that is something I'd like to support.

@DavidBuchanan314
Copy link
Owner Author

32-bit builds are now prevented by 4f257db, but I'd still like to fix this properly

@DavidBuchanan314 DavidBuchanan314 mentioned this issue Feb 23, 2024
19 tasks
@DavidBuchanan314
Copy link
Owner Author

DavidBuchanan314 commented Dec 29, 2024

One issue here is confusion between size_t (which is (usually) 32-bit on 32-bit platforms) and CBOR lengths, which are 64-bit.

I should probably make a cbor_length_to_size_t() helper, which is a nop on 64-bit systems, and errors on 32-bit systems if the size is too big

@DavidBuchanan314
Copy link
Owner Author

SIZE_MAX from limits.h will tell us the max size that size_t can hold. ((uint64_t)-1) tells us the max size that uint64_t can hold.

@DavidBuchanan314
Copy link
Owner Author

7bb3b1b fixed a bug on 32-bit platforms, and aside from that it works, but may still be unsafe.

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