well, I read data to buffer using read_until - it's easy to check it's size after that. What about aborting reading after excesses some defined limit of package length?
PS Also
std::string s((istreambuf_iterator<char>(someStreamBuf)),
istreambuf_iterator<char>());
Doesn't work properly - it cuts part of last line (everything after 20 symbols). Strange.
PPS Which other cases should I work through to secure server-like application? (I.e. buffer overflow)