Fix mkdir time of check to time of use (TOCTOU) issue

This commit is contained in:
Markus Gans 2018-09-18 03:09:14 +02:00
parent b97fa7c61f
commit fec12f5d64
2 changed files with 8 additions and 10 deletions

View File

@ -1122,24 +1122,24 @@ void FOptiMove::moveByMethod ( int method
if ( F_carriage_return.cap )
{
std::strncpy (move_ptr, F_carriage_return.cap, BUF_SIZE);
move_buf[BUF_SIZE - 1] ='\0';
move_ptr += F_carriage_return.length;
relativeMove (move_ptr, 0, yold, xnew, ynew);
move_buf[BUF_SIZE - 1] ='\0';
}
break;
case 3:
std::strncpy (move_ptr, F_cursor_home.cap, BUF_SIZE);
move_buf[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_home.length;
relativeMove (move_ptr, 0, 0, xnew, ynew);
move_buf[BUF_SIZE - 1] ='\0';
break;
case 4:
std::strncpy (move_ptr, F_cursor_to_ll.cap, BUF_SIZE);
move_buf[BUF_SIZE - 1] ='\0';
move_ptr += F_cursor_to_ll.length;
relativeMove (move_ptr, 0, screen_height - 1, xnew, ynew);
move_buf[BUF_SIZE - 1] ='\0';
break;
case 5:
@ -1153,9 +1153,9 @@ void FOptiMove::moveByMethod ( int method
std::strncat ( move_ptr
, F_cursor_left.cap
, BUF_SIZE - std::strlen(move_ptr) );
move_buf[BUF_SIZE - 1] ='\0';
move_ptr += std::strlen(move_buf);
relativeMove (move_ptr, screen_width - 1, yold - 1, xnew, ynew);
move_buf[BUF_SIZE - 1] ='\0';
break;
default:

View File

@ -1663,14 +1663,12 @@ void FTermDetectionTest::tmuxTest()
//----------------------------------------------------------------------
void FTermDetectionTest::ttytypeTest()
{
struct stat sb = { };
if ( stat("new-root-dir", &sb) == -1 )
if ( mkdir("new-root-dir", 0755) == -1 )
if ( mkdir("new-root-dir", 0755) == -1 )
if ( errno != EEXIST )
return;
if ( stat("new-root-dir/etc", &sb) == -1 )
if ( mkdir("new-root-dir/etc", 0755) == -1 )
if ( mkdir("new-root-dir/etc", 0755) == -1 )
if ( errno != EEXIST )
return;
// Write a own /etc/ttytype file