Today I've discovered that the following compiles and prints 42:
#include <iostream>
#include <sstream>
int main()
{
std::stringstream s;
s << 42;
char c[8];
s >> c;
std::cout << c;
}
But this is a potential buffer overflow attack, right? If we are reading from the user-supplied stream, we can't easily know the size of the data and therefore can't allocate enough storage. std::gets
was removed, maybe this should be too?