Skip to content

Commit 8aa2bf4

Browse files
committed
tvdemo: prevent buffer overrun in file viewer
By allowing no more than maxLineLength+1 bytes being written into the array.
1 parent 86e2c3d commit 8aa2bf4

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎examples/tvdemo/fileview.cpp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ void TFileViewer::draw()
7272
if( p == 0 || strlen(p) < delta.x )
7373
s[0] = EOS;
7474
else
75-
{
76-
strncpy( s, p+delta.x, size.x );
77-
s[size.x] = EOS;
78-
}
75+
strnzcpy( s, p+delta.x, maxLineLength+1 );
7976
b.moveStr( 0, s, c );
8077
}
8178
writeBuf( 0, i, (short)size.x, 1, b );

0 commit comments

Comments
 (0)