knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

Fix: Vulnerability in Comparison of different type sizes #1001

Open FeedehC opened 1 year ago

FeedehC commented 1 year ago

Little change in sizes of for loop iterator "i", from uint16_t to uint32_t, to avoid possible infinite loop, which depends on the value of "plength". More information in issue: https://github.com/knolleary/pubsubclient/issues/1000

Flole998 commented 1 year ago

Well, now length could potentially overflow so the buffer is incorrectly filled. Also you're still mixing datatypes, an unsigned int and an uint32_t could potentially have different sizes, so I suggest to use unsigned int for the length everywhere.