From cd17687f01420952712a500107e0f93e7ab8d5f8 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:34 -0500 Subject: Second Life viewer sources 1.19.1.0 --- linden/indra/llcommon/llstreamtools.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'linden/indra/llcommon/llstreamtools.cpp') diff --git a/linden/indra/llcommon/llstreamtools.cpp b/linden/indra/llcommon/llstreamtools.cpp index 5419b24..669bdd0 100644 --- a/linden/indra/llcommon/llstreamtools.cpp +++ b/linden/indra/llcommon/llstreamtools.cpp @@ -538,23 +538,32 @@ void get_keyword_and_value(std::string& keyword, } } -std::istream& fullread(std::istream& str, char *buf, std::streamsize requested) +std::streamsize fullread( + std::istream& istr, + char* buf, + std::streamsize requested) { std::streamsize got; std::streamsize total = 0; - str.read(buf, requested); /*Flawfinder: ignore*/ - got = str.gcount(); + istr.read(buf, requested); /*Flawfinder: ignore*/ + got = istr.gcount(); total += got; - while (got && total < requested) + while(got && total < requested) { - if (str.fail()) - str.clear(); - str.read(buf + total, requested - total); /*Flawfinder: ignore*/ - got = str.gcount(); + if(istr.fail()) + { + // If bad is true, not much we can doo -- it implies loss + // of stream integrity. Bail in that case, and otherwise + // clear and attempt to continue. + if(istr.bad()) return total; + istr.clear(); + } + istr.read(buf + total, requested - total); /*Flawfinder: ignore*/ + got = istr.gcount(); total += got; } - return str; + return total; } std::istream& operator>>(std::istream& str, const char *tocheck) -- cgit v1.1