Skip to content

net/unicoap: Message initialisers do not set .payload_representation #22285

@carl-tud

Description

@carl-tud

unicoap message initialisers (see sys/include/net/unicoap/message.h) do not set the payload_representation property to UNICOAP_PAYLOAD_REPRESENTATION_CONTIGUOUS. The point of these initialisers is that one does not need to zero a message structure before. However, right now, the representation might be randomly set to the wrong representation, which trivially leads to a segfault.

unicoap_message_t message;
unicoap_message_init_string(...); // May end up with with wrong payload representation 
unicoap_message_t message = {};
unicoap_message_init_string(...); // Works because is zeroed before.

Fix by setting message->payload_representation = UNICOAP_PAYLOAD_REPRESENTATION_CONTIGUOUS in initialisers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: CoAPArea: Constrained Application Protocol implementationsArea: networkArea: NetworkingType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions