diff options
Diffstat (limited to 'firmware/drivers/lcd-charcell.c')
-rw-r--r-- | firmware/drivers/lcd-charcell.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c index 36f1d26487..f928c19ecd 100644 --- a/firmware/drivers/lcd-charcell.c +++ b/firmware/drivers/lcd-charcell.c | |||
@@ -513,9 +513,10 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | |||
513 | { | 513 | { |
514 | /* prepare scroll line */ | 514 | /* prepare scroll line */ |
515 | char *end; | 515 | char *end; |
516 | int count; | ||
516 | 517 | ||
517 | memset(s->line, 0, sizeof s->line); | 518 | memset(s->line, 0, sizeof s->line); |
518 | strcpy(s->line, string); | 519 | strlcpy(s->line, string, sizeof s->line); |
519 | 520 | ||
520 | /* get width */ | 521 | /* get width */ |
521 | s->len = utf8length(s->line); | 522 | s->len = utf8length(s->line); |
@@ -531,13 +532,15 @@ void lcd_puts_scroll_offset(int x, int y, const unsigned char *string, | |||
531 | 532 | ||
532 | if (!s->bidir) /* add spaces if scrolling in the round */ | 533 | if (!s->bidir) /* add spaces if scrolling in the round */ |
533 | { | 534 | { |
534 | strcat(s->line, " "); | 535 | strlcat(s->line, " ", sizeof s->line); |
535 | /* get new width incl. spaces */ | 536 | /* get new width incl. spaces */ |
536 | s->len += SCROLL_SPACING; | 537 | s->len += SCROLL_SPACING; |
537 | } | 538 | } |
538 | 539 | ||
539 | end = strchr(s->line, '\0'); | 540 | end = strchr(s->line, '\0'); |
540 | strlcpy(end, string, utf8seek(s->line, current_vp->width)); | 541 | len = sizeof s->line - (end - s->line); |
542 | count = utf8seek(s->line, current_vp->width); | ||
543 | strlcpy(end, string, MIN(count, len)); | ||
541 | 544 | ||
542 | s->vp = current_vp; | 545 | s->vp = current_vp; |
543 | s->y = y; | 546 | s->y = y; |