mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-22 00:56:21 +03:00
Fix buffer length curtailing
Thislen is the payload of the received data, which should not exceed the buffer length minus 4 bytes header.
This commit is contained in:
@@ -758,9 +758,9 @@ static int jtag3_edbg_recv_frame(const PROGRAMMER *pgm, unsigned char **msg) {
|
||||
|
||||
int thislen = (buf[2] << 8) | buf[3];
|
||||
|
||||
if(thislen > rv + 4) {
|
||||
pmsg_notice("%s(): unexpected length value (%d > %d)\n", __func__, thislen, rv + 4);
|
||||
thislen = rv + 4;
|
||||
if(thislen > rv - 4) {
|
||||
pmsg_notice("%s(): unexpected length (%d > %d)\n", __func__, thislen, rv - 4);
|
||||
thislen = rv - 4;
|
||||
}
|
||||
if(len + thislen > USBDEV_MAX_XFER_3) {
|
||||
pmsg_notice("%s(): length exceeds max size (%d > %d)\n", __func__, len + thislen, USBDEV_MAX_XFER_3);
|
||||
|
||||
Reference in New Issue
Block a user