Browse Source

Null-terminate lcd_status_message

pull/1/head
Scott Lahteine 7 years ago
parent
commit
25e3e62354
  1. 7
      Marlin/src/lcd/ultralcd.cpp

7
Marlin/src/lcd/ultralcd.cpp

@ -5172,6 +5172,7 @@ void lcd_update() {
inline void pad_message_string() {
uint8_t i = 0, j = 0;
char c;
lcd_status_message[MAX_MESSAGE_LENGTH] = '\0';
while ((c = lcd_status_message[i]) && j < LCD_WIDTH) {
if (PRINTABLE(c)) j++;
i++;
@ -5221,7 +5222,7 @@ bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
void lcd_setstatus(const char * const message, const bool persist) {
if (lcd_status_message_level > 0) return;
strncpy(lcd_status_message, message, COUNT(lcd_status_message) - 1);
strncpy(lcd_status_message, message, MAX_MESSAGE_LENGTH);
lcd_finishstatus(persist);
}
@ -5229,7 +5230,7 @@ void lcd_setstatusPGM(const char * const message, int8_t level) {
if (level < 0) level = lcd_status_message_level = 0;
if (level < lcd_status_message_level) return;
lcd_status_message_level = level;
strncpy_P(lcd_status_message, message, COUNT(lcd_status_message) - 1);
strncpy_P(lcd_status_message, message, MAX_MESSAGE_LENGTH);
lcd_finishstatus(level > 0);
}
@ -5238,7 +5239,7 @@ void lcd_status_printf_P(const uint8_t level, const char * const fmt, ...) {
lcd_status_message_level = level;
va_list args;
va_start(args, fmt);
vsnprintf_P(lcd_status_message, COUNT(lcd_status_message) - 1, fmt, args);
vsnprintf_P(lcd_status_message, MAX_MESSAGE_LENGTH, fmt, args);
va_end(args);
lcd_finishstatus(level > 0);
}

Loading…
Cancel
Save