Skip to content

Commit

Permalink
avoid buffer overflow in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
imwhocodes committed Feb 10, 2024
1 parent 29288a0 commit bf39067
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cores/esp32/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,16 @@ uartDetectBaudrate(uart_t *uart)
}

log_v("Rounded\t%d\tto\t%d", baudrate, default_rates[i]);
log_v("From Previous\t( %d )\t:\t( %d )", default_rates[i-1], baudrate - default_rates[i-1] ); //THIS WILL OVERFLOW, only for testing now
log_v("From Current\t( %d )\t:\t( %d )", default_rates[i], default_rates[i] - baudrate); //THIS WILL OVERFLOW, only for testing now
log_v("From Next\t( %d )\t:\t( %d )", default_rates[i+1], default_rates[i+1] - baudrate); //THIS WILL OVERFLOW, only for testing now

if(i>0){
log_v("From Previous\t( %d )\t:\t( %d )", default_rates[i-1], baudrate - default_rates[i-1] );
}

log_v("From Current\t( %d )\t:\t( %d )", default_rates[i], default_rates[i] - baudrate);

if(i < ( sizeof(default_rates) / sizeof(default_rates[0]) - 2 ) ){
log_v("From Next\t( %d )\t:\t( %d )", default_rates[i+1], default_rates[i+1] - baudrate);
}

return default_rates[i];
#else
Expand Down

0 comments on commit bf39067

Please sign in to comment.