forked from len0rd/rockbox
Buffer overrun fix by Craigh Sather (#852494)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4106 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
caff78802b
commit
0d2237402e
1 changed files with 14 additions and 8 deletions
|
@ -120,7 +120,7 @@ static void wps_format(char* fmt)
|
||||||
format_buffer[sizeof(format_buffer) - 1] = 0;
|
format_buffer[sizeof(format_buffer) - 1] = 0;
|
||||||
format_lines[line] = buf;
|
format_lines[line] = buf;
|
||||||
|
|
||||||
while (*buf)
|
while ((*buf) && (line < MAX_LINES))
|
||||||
{
|
{
|
||||||
switch (*buf)
|
switch (*buf)
|
||||||
{
|
{
|
||||||
|
@ -134,7 +134,7 @@ static void wps_format(char* fmt)
|
||||||
if(*start_of_line != '#') /* A comment? */
|
if(*start_of_line != '#') /* A comment? */
|
||||||
line++;
|
line++;
|
||||||
|
|
||||||
if (line <= MAX_LINES)
|
if (line < MAX_LINES)
|
||||||
{
|
{
|
||||||
/* the next line starts on the next byte */
|
/* the next line starts on the next byte */
|
||||||
format_lines[line] = buf+1;
|
format_lines[line] = buf+1;
|
||||||
|
@ -145,13 +145,19 @@ static void wps_format(char* fmt)
|
||||||
buf++;
|
buf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buf != format_lines[line])
|
/* if supplied input didn't define a format line
|
||||||
/* the last line didn't terminate with a newline */
|
for each line on the wps, set the rest to null */
|
||||||
line++;
|
if (line < MAX_LINES)
|
||||||
|
|
||||||
for (; line < MAX_LINES; line++)
|
|
||||||
{
|
{
|
||||||
format_lines[line] = NULL;
|
/* if the final line didn't terminate with a newline,
|
||||||
|
the line index wasn't incremented */
|
||||||
|
if (buf != format_lines[line])
|
||||||
|
line++;
|
||||||
|
|
||||||
|
for (; line < MAX_LINES; line++)
|
||||||
|
{
|
||||||
|
format_lines[line] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue