forked from len0rd/rockbox
avoid overflow in puts_scroll().
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26231 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e2d1eb6fc8
commit
0ac61bffa7
2 changed files with 10 additions and 5 deletions
|
@ -321,6 +321,7 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
|
|||
struct scrollinfo* s;
|
||||
char *end;
|
||||
int w, h;
|
||||
int len;
|
||||
|
||||
if ((unsigned)y >= (unsigned)current_vp->height)
|
||||
return;
|
||||
|
@ -358,13 +359,14 @@ void LCDFN(puts_scroll_style_offset)(int x, int y, const unsigned char *string,
|
|||
s->bidir = false;
|
||||
|
||||
if (!s->bidir) { /* add spaces if scrolling in the round */
|
||||
strcat(s->line, " ");
|
||||
strlcat(s->line, " ", sizeof s->line);
|
||||
/* get new width incl. spaces */
|
||||
s->width = LCDFN(getstringsize)(s->line, &w, &h);
|
||||
}
|
||||
|
||||
end = strchr(s->line, '\0');
|
||||
strlcpy(end, string, current_vp->width/2);
|
||||
len = sizeof s->line - (end - s->line);
|
||||
strlcpy(end, string, MIN(current_vp->width/2, len));
|
||||
|
||||
s->vp = current_vp;
|
||||
s->y = y;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue