From 8aa2bf4af4474b85e86e340b08d7c56081b68986 Mon Sep 17 00:00:00 2001 From: magiblot Date: Tue, 12 Nov 2019 22:42:11 +0100 Subject: [PATCH] tvdemo: prevent buffer overrun in file viewer By allowing no more than maxLineLength+1 bytes being written into the array. --- examples/tvdemo/fileview.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/examples/tvdemo/fileview.cpp b/examples/tvdemo/fileview.cpp index a70896f0..343ea1a2 100644 --- a/examples/tvdemo/fileview.cpp +++ b/examples/tvdemo/fileview.cpp @@ -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 );