adafruit / Adafruit_CircuitPython_Wiznet5k

Pure-Python interface for WIZNET 5k Ethernet modules
Other
15 stars 37 forks source link

Fix for issue #108 - Make sure the buffer is large enough before ever… #110

Closed dgnuff closed 1 year ago

dgnuff commented 1 year ago

Added a const value for the buffer size. Used that value for both the initial buffer allocation, and the buffer re-initialization in preparation for sending packets.

This prevents a buffer overflow when building the DHCPREQUEST packet because the buffer appears to have shrunk while processing the DHCPOFFER reply.

dgnuff commented 1 year ago

Running my eyes over it, I can see no reason at all for _BUFF to be global. And indeed, this is a copy-book example of why globals are bad, because code in function A modifies the global, causing a bug in function B.