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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 3.2.0-rc0
    • Affects Version/s: None
    • Component/s: Implementation
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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:
            Samuel Rossi (Inactive)
            Reporter:
            Samuel Rossi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: