Skip to content

Commit

Permalink
tvdemo: prevent buffer overrun in file viewer
Browse files Browse the repository at this point in the history
By allowing no more than maxLineLength+1 bytes being written into the array.
  • Loading branch information
magiblot committed Nov 12, 2019
1 parent 86e2c3d commit 8aa2bf4
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions examples/tvdemo/fileview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ void TFileViewer::draw()
if( p == 0 || strlen(p) < delta.x )
s[0] = EOS;
else
{
strncpy( s, p+delta.x, size.x );
s[size.x] = EOS;
}
strnzcpy( s, p+delta.x, maxLineLength+1 );
b.moveStr( 0, s, c );
}
writeBuf( 0, i, (short)size.x, 1, b );
Expand Down

0 comments on commit 8aa2bf4

Please sign in to comment.