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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0-rc0
    • Affects Version/s: None
    • Component/s: Implementation
    • Labels:
      None

      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);
      

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

              Created:
              Updated:
              Resolved: