bl_sendDataBlock(): Fix buffer overflow.

This commit is contained in:
Gerhard Hoffmann 2024-02-09 12:51:11 +01:00
parent 544bab4332
commit 3fc8562a2b

View File

@ -2640,12 +2640,23 @@ void hwapi::bl_openBinary(void) const
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
{
// send 64 byte from bin file
uint8_t LL=length, sendBuf[80], sendLen;
// gh, 09/02/2024: extend sendBuf. Buffer sometimes too small, sendLen=81
uint8_t LL=length, sendBuf[80+32], sendLen;
if (LL>64) LL=64;
tslib_strclr(sendBuf,0,80);
memset(sendBuf, 0, sizeof(sendBuf));
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
// qCritical() << "(" __func__ << ":" << __LINE__ << ") sendLen=" << sendLen
// << ":" << QByteArray((const char *)sendBuf, sendLen);
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
// if (sendLen > 80) {
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// << QByteArray((const char *)&sendBuf[80], 32).toHex(':');
// }
delay(100);
}