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

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.2.0-rc0
    • Implementation
    • None
    • 1

    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

              sam.rossi@mongodb.com Samuel Rossi (Inactive)
              sam.rossi@mongodb.com Samuel Rossi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: