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

fix: Fix incorrect data size handling in struct layout Update mod.rs #372

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

brawncode
Copy link

An issue with the struct layout where Size and Data were incorrectly assumed to have fixed sizes. Specifically, Size was defined as u32 (4 bytes), followed by Data (incorrectly assumed to always be 4 bytes), and then C (CRC32, 4 bytes). This doesn't align with the actual requirements since Data can have a variable length. I've updated the implementation to correctly handle Data as a variable-length field, ensuring the struct layout matches the intended design. This should resolve any inconsistencies in memory alignment and data parsing.

@@ -15,7 +15,7 @@
//!
//! ```text
//! +---+---+---+---+---+---+---+---+---+---+---+
//! | 0 | 1 | 2 | 3 | ... | 8 | 9 |10 |11 |
//! | 0 | 1 | 2 | 3 | ... | N |N+1|N+2|N+3|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a fair suggestion. Would you mind indicating below C = CRC32(Data) what N is?

Wonder if it would be clear to just call it D (for Data) and do D+4, D+5, D+6, D+7 for size (incorporating values from before)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, N is a variable representing a starting index from which the numbering continues as N, N+1, N+2, N+3.

Yes, we can absolutely name the variable D instead of N. The choice of variable name is arbitrary and depends on the context or the developer's preference. The name N is often used to represent a generic number or index, but D could also be a valid choice, especially if it aligns better with the meaning or purpose of the variable in your code.

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

Successfully merging this pull request may close these issues.

2 participants