hirotakaster / MQTT

MQTT for Photon, Spark Core
Other
216 stars 118 forks source link

Avoid buffer overruns #21

Closed ckrey closed 8 years ago

ckrey commented 8 years ago

in publish

        // was: for (i=0;i<plength;i++) {
        for (i=0;i<plength && length < MQTT_MAX_PACKET_SIZE;i++) { // new
            buffer[length++] = payload[i];
        }

and writeString

    pos += 2;
    // was: while (*idp) {
    while (*idp && pos < MQTT_MAX_PACKET_SIZE) { // new
        buf[pos++] = *idp++;
        i++;
    }```
hirotakaster commented 8 years ago

thank you for your check.