Skip to content

readBin() is not "type-length-safe" #38

@sigmaeo

Description

@sigmaeo

If you use:
uint32_t ui32 = cm.readBinArg();
Then readBinArg() or readBin() will read 4 Bytes from the receiving buffer, ignoring the real length of what is sent and any seperator that may come earlier.
If you send (with ID=1):

1,ABCD;

(with A=0x41, B=0x42, C=0x43, D=0x44) you will get as expected:
0x44434241 = 1145258561.
But if you send:

1,A;

you don't get 0x41 = 65, instead you will get a random value with 0x41 as LSB, 0x00 after it and 2 more "random" bytes from memory.

And ArgOk is not updated.

This should be enhanced with a test if the length (that slpit_r() sees) is big enough, but for this some more changes are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions