[Cmake] Buffer overflows

Amitha Perera perera at cs.rpi.edu
Fri Jun 22 03:58:50 EDT 2001


Could we please, please avoid using fixed-sized buffers, no matter
how big the buffer is? I just spent the last 3 hrs tracking down
 char  buff[4096]
in cmSystemTools::cmCopyFile.

Is there any reason why this function couldn't be implemented using
iterators? For example:

void cmSystemTools::cmCopyFile(const char* source,
                             const char* destination)
{
  std::ifstream fin(source);
  std::ofstream fout(destination);
  std::copy( std::istream_iterator<char>(fin), std::istream_iterator<char>(), std::ostream_iterator<char>(fout) );
}

Amitha.




More information about the CMake mailing list