diff options
Diffstat (limited to 'linden/indra/llcommon/llstreamtools.cpp')
-rw-r--r-- | linden/indra/llcommon/llstreamtools.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
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, | |||
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | std::istream& fullread(std::istream& str, char *buf, std::streamsize requested) | 541 | std::streamsize fullread( |
542 | std::istream& istr, | ||
543 | char* buf, | ||
544 | std::streamsize requested) | ||
542 | { | 545 | { |
543 | std::streamsize got; | 546 | std::streamsize got; |
544 | std::streamsize total = 0; | 547 | std::streamsize total = 0; |
545 | 548 | ||
546 | str.read(buf, requested); /*Flawfinder: ignore*/ | 549 | istr.read(buf, requested); /*Flawfinder: ignore*/ |
547 | got = str.gcount(); | 550 | got = istr.gcount(); |
548 | total += got; | 551 | total += got; |
549 | while (got && total < requested) | 552 | while(got && total < requested) |
550 | { | 553 | { |
551 | if (str.fail()) | 554 | if(istr.fail()) |
552 | str.clear(); | 555 | { |
553 | str.read(buf + total, requested - total); /*Flawfinder: ignore*/ | 556 | // If bad is true, not much we can doo -- it implies loss |
554 | got = str.gcount(); | 557 | // of stream integrity. Bail in that case, and otherwise |
558 | // clear and attempt to continue. | ||
559 | if(istr.bad()) return total; | ||
560 | istr.clear(); | ||
561 | } | ||
562 | istr.read(buf + total, requested - total); /*Flawfinder: ignore*/ | ||
563 | got = istr.gcount(); | ||
555 | total += got; | 564 | total += got; |
556 | } | 565 | } |
557 | return str; | 566 | return total; |
558 | } | 567 | } |
559 | 568 | ||
560 | std::istream& operator>>(std::istream& str, const char *tocheck) | 569 | std::istream& operator>>(std::istream& str, const char *tocheck) |