[Cmake] Buffer overflows

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


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.