Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1322

gridfs::bucket::upload_from_stream and upload_from_stream_with_id infinitely loop on invalid ifstream without error bits set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2.0-rc0
    • Component/s: Implementation
    • Labels:
      None
    • Story Points:
      1
    • Sprint:
      Perl/CXX 2017-05-05

      Description

      If an invalid ifstream (e.g. one pointing to a non-existent file) without error bits set is passed to gridfs::bucket::upload_from_stream (or gridfs::bucket::upload_from_stream_with_id), the method will infinitely loop. This is because istream::read only throws an exception if `badbit` is set.

      The most straightforward fix for this would be to set the error bits at the beginning of upload_from_stream_with_id so that errors will throw exceptions (and then document that this is the case):

      source->exceptions(std::io::failbit | std::io::badbit);
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: