fix potential oob access and resend command on i2c failure

This commit is contained in:
Alessandro Mauri 2026-09-17 22:25:26 +02:00
parent a7acfa91d6
commit 976971532a

View File

@ -133,7 +133,7 @@ static uint8_t u8x8_gpio_and_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, v
static uint8_t u8x8_byte_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) static uint8_t u8x8_byte_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
{ {
static uint8_t buffer[32]; static uint8_t buffer[256];
static uint8_t buffer_idx; static uint8_t buffer_idx;
uint8_t *data; uint8_t *data;
@ -152,7 +152,7 @@ static uint8_t u8x8_byte_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *a
buffer_idx = 0; buffer_idx = 0;
break; break;
case U8X8_MSG_BYTE_END_TRANSFER: case U8X8_MSG_BYTE_END_TRANSFER:
i2c_sendBytes(I2C_TARGET, u8x8_GetI2CAddress(u8x8) >> 1, buffer, buffer_idx); while(i2c_sendBytes(I2C_TARGET, u8x8_GetI2CAddress(u8x8) >> 1, buffer, buffer_idx) != 0);
break; break;
default: default:
return 0; return 0;