From 82f1b7e44c9908e628ac14f86ebda8318a8c6643 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 18 Sep 2017 00:10:14 +0200 Subject: [PATCH] std::scanf used now fields with width limit --- ChangeLog | 1 + src/fapplication.cpp | 2 +- src/fterm.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 435b8ba6..18e29da6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,7 @@ * FObject has received the iterator child access methods begin() and end() * All include files were moved to a separate directory + * std::scanf used now fields with width limit 2017-09-15 Markus Gans * Fix byte access in data type char_data diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 3989f139..a50118c7 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -497,7 +497,7 @@ void FApplication::processKeyboardEvent() widget->focusFirstChild(); } - // empty the buffer on timeout + // Empty the buffer on timeout if ( fifo_in_use && widget->isKeyTimeout(&time_keypressed, key_timeout) ) { fifo_offset = 0; diff --git a/src/fterm.cpp b/src/fterm.cpp index 2527b66b..559c6b2e 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -903,7 +903,7 @@ const FString* FTerm::getXTermFont() { char temp[150] = {}; - if ( std::scanf("\033]50;%[^\n]s", temp) == 1 ) + if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 ) { FString* xtermfont; std::size_t n = std::strlen(temp); @@ -952,7 +952,7 @@ const FString* FTerm::getXTermTitle() { char temp[512] = {}; - if ( std::scanf("\033]l%[^\n]s", temp) == 1 ) + if ( std::scanf("\033]l%509[^\n]s", temp) == 1 ) { std::size_t n = std::strlen(temp); @@ -1009,7 +1009,7 @@ const FString FTerm::getXTermColorName (int color) // read the terminal answer if ( select (stdin_no + 1, &ifds, 0, 0, &tv) > 0) { - if ( std::scanf("\033]4;%d;%[^\n]s", &color, temp) == 2 ) + if ( std::scanf("\033]4;%10d;%509[^\n]s", &color, temp) == 2 ) { std::size_t n = std::strlen(temp); @@ -1536,7 +1536,7 @@ const FString FTerm::getSecDA() // read the answer if ( select (stdin_no + 1, &ifds, 0, 0, &tv) == 1 ) - if ( std::scanf("\033[>%d;%d;%dc", &a, &b, &c) == 3 ) + if ( std::scanf("\033[>%10d;%10d;%10dc", &a, &b, &c) == 3 ) sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); return sec_da_str;