Skip to content

Length calculation wrong; buffer overrun ? #1071

Open
@dirkx

Description

@dirkx

After fighting with some odd topic-corruption (in a const char* no less) -- I think that the calculation in this line:

for (i=0;i<plength;i++) {
the length is a bit overoptimistic; as at that point up to length has already been used by the topic; while plength is either capped by buffSize; e.g. here:
return publish(topic,(const uint8_t*)payload, payload ? strnlen(payload, this->bufferSize) : 0,false);
or when called in full not at all: e.g. here:
boolean PubSubClient::publish(const char* topic, const uint8_t* payload, unsigned int plength, boolean retained) {

So it should perhaps read i < plength && length < buffSize

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