summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/modules/webrepl.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-09-01 11:11:09 +1000
committerDamien George <damien.p.george@gmail.com>2017-09-01 11:11:09 +1000
commit2daacc5ceef7e36ac3c88b8946088b6b3513993b (patch)
treeb3a0379793c68632162c8cb8fac9ff8948426a1e /esp8266/modules/webrepl.py
parent79d5acbd01fed21e1c8e46b06690072375de0bfe (diff)
downloadmicropython-2daacc5ceef7e36ac3c88b8946088b6b3513993b.tar.gz
micropython-2daacc5ceef7e36ac3c88b8946088b6b3513993b.zip
py/modstruct: Check and prevent buffer-write overflow in struct packing.
Prior to this patch, the size of the buffer given to pack_into() was checked for being too small by using the count of the arguments, not their actual size. For example, a format spec of '4I' would only check that there was 4 bytes available, not 16; and 'I' would check for 1 byte, not 4. The pack() function is ok because its buffer is created to be exactly the correct size. The fix in this patch calculates the total size of the format spec at the start of pack_into() and verifies that the buffer is large enough. This adds some computational overhead, to iterate through the whole format spec. The alternative is to check during the packing, but that requires extra code to handle alignment, and the check is anyway not needed for pack(). So to maintain minimal code size the check is done using struct_calcsize.
Diffstat (limited to 'esp8266/modules/webrepl.py')
0 files changed, 0 insertions, 0 deletions