From 09d6c2879d433653584329bae327d83742464e50 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 15 Apr 2017 19:32:43 +0200 Subject: [PATCH] Fix unsigned integer underflow in FString::_insert() --- ChangeLog | 3 +++ src/fstring.cpp | 2 +- src/fterm.cpp | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16ada43f..71a6a0bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2017-04-15 Markus Gans + * Fix unsigned integer underflow in FString::_insert() + 2017-04-14 Markus Gans * The Final Cut compiles also under OpenBSD * The alt key now always generates an esc prefix diff --git a/src/fstring.cpp b/src/fstring.cpp index 9ef28480..d370e88c 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -2267,7 +2267,7 @@ inline void FString::_insert (uInt pos, uInt len, const wchar_t* s) if ( (length + len + 1) <= bufsize ) { // output string <= bufsize - for (x = length; x > pos-1; x--) // shifting right side + '\0' + for (x = length; x+1 > pos; x--) // shifting right side + '\0' string[x+len] = string[x]; for (x=0; x < len; x++) // insert string diff --git a/src/fterm.cpp b/src/fterm.cpp index c78c0276..96aaf924 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -2723,16 +2723,20 @@ char* FTerm::parseSecDA (char*& current_termtype) case 19: // DEC VT340 case 24: // DEC VT320 - if ( terminal_id_version == 20 ) +#if defined(__NetBSD__) || defined(__OpenBSD__) + if ( terminal_id_version == 20 && isWSConsConsole() ) { // NetBSD/OpenBSD workstation console if ( std::strncmp(termtype, const_cast("wsvt25"), 6) == 0 ) netbsd_terminal = true; else if ( std::strncmp(termtype, const_cast("vt220"), 5) == 0 ) + { openbsd_terminal = true; + new_termtype = const_cast("pccon"); + } } break; - +#endif case 41: // DEC VT420 case 61: // DEC VT510 case 64: // DEC VT520