Skip to content

Potential bug in example code  #65

@SebastianSchildt

Description

@SebastianSchildt

There lurks a potentially nasty bug in the example in the toplevel Readme

Open1722/README.md

Lines 148 to 149 in 7fe06a3

Avtp_Lin_t lin;
uint8_t linPayload[LIN_PAYLOAD_LEN];

C standard does not guarantee that uint8_t linPayload[LIN_PAYLOAD_LEN]; follows in memory after Avtp_Lin_t lin; there might be gaps in between due to alignment. Thus the memcpy in the end may copy an invalid frame.

I think either we change the example using a more robust pattern, or at least warn about this (there are some non-standard tags in some compilers to force it to create packed structs)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions