diff --git a/src/foptimove.cpp b/src/foptimove.cpp index b190797c..571d8dcc 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -690,9 +690,9 @@ int FOptiMove::relativeMove ( char move[] if ( move ) { if ( *move ) - std::strncat (move, hmove, BUF_SIZE - std::strlen(move)); + std::strncat (move, hmove, BUF_SIZE - std::strlen(move) - 1); else - std::strncpy (move, hmove, BUF_SIZE); + std::strncpy (move, hmove, BUF_SIZE - 1); move[BUF_SIZE - 1] = '\0'; } @@ -854,7 +854,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime if ( htime_r < htime ) { - std::strncpy (hmove, str, BUF_SIZE); + std::strncpy (hmove, str, BUF_SIZE - 1); hmove[BUF_SIZE - 1] = '\0'; htime = htime_r; } diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 8ee741c8..f9952421 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -145,7 +145,7 @@ void FTermDetection::getSystemTermType() } // 2nd fallback: use vt100 if not found - std::strncpy (termtype, C_STR("vt100"), 6); + std::strncpy (termtype, C_STR("vt100"), 5); } //---------------------------------------------------------------------- @@ -514,7 +514,7 @@ const FString FTermDetection::getXTermColorName (int color) int stdin_no = FTermios::getStdIn(); char temp[512] = { }; - std::fprintf (stdout, OSC "4;%d;?" BEL, color); // get color + std::fprintf (stdout, OSC "4;%3d;?" BEL, color); // get color std::fflush(stdout); FD_ZERO(&ifds); @@ -579,7 +579,7 @@ char* FTermDetection::parseAnswerbackMsg (char current_termtype[]) { std::strncpy ( termtype_Answerback , new_termtype - , sizeof(termtype_Answerback) ); + , sizeof(termtype_Answerback) - 1); termtype_Answerback[sizeof(termtype_Answerback) - 1] = '\0'; } #endif // DEBUG diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index 70f38c74..4c946041 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -234,7 +234,6 @@ class FOptiMove bool automatic_left_margin; bool eat_nl_glitch; - char move_buf[BUF_SIZE]; int char_duration; int baudrate; diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index aa050ed4..6e09b686 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -363,7 +363,7 @@ inline void FTermData::setTermType (const char name[]) if ( ! name ) return; - std::strncpy (termtype, name, sizeof(termtype)); + std::strncpy (termtype, name, sizeof(termtype) - 1); termtype[sizeof(termtype) - 1] = '\0'; } @@ -373,7 +373,7 @@ inline void FTermData::setTermFileName (const char file_name[]) if ( ! file_name ) return; - std::strncpy (termfilename, file_name, sizeof(termfilename)); + std::strncpy (termfilename, file_name, sizeof(termfilename) - 1); termfilename[sizeof(termfilename) - 1] = '\0'; } diff --git a/test/fstring-test.cpp b/test/fstring-test.cpp index a61f5ee4..bbcf7d7b 100644 --- a/test/fstring-test.cpp +++ b/test/fstring-test.cpp @@ -1016,7 +1016,7 @@ void FStringTest::formatTest() str1.sprintf ("There are %d lions in the %s", num, location); CPPUNIT_ASSERT ( str1 == "There are 3 lions in the zoo" ); - str1.sprintf (finalcut::FString("%d times"), 42); + str1.sprintf (finalcut::FString("%2d times"), 42); CPPUNIT_ASSERT ( str1 == "42 times" ); finalcut::FString str2;