strncpy boundary
This commit is contained in:
parent
baabf9546e
commit
9fc1910c18
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -234,7 +234,6 @@ class FOptiMove
|
|||
|
||||
bool automatic_left_margin;
|
||||
bool eat_nl_glitch;
|
||||
|
||||
char move_buf[BUF_SIZE];
|
||||
int char_duration;
|
||||
int baudrate;
|
||||
|
|
|
@ -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';
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue