Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11903

Remove BSONElement::validate()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.4.8
    • 2.5.5
    • None
    • None
    • Minor Change
    • ALL

    Description

      Original title: BSONElement.validate() success on invalid BSON

      There have been cases where BSONElement.validate() fails to recognize that an element is invalid. In the following code in tool.cpp we see the following:

                  BSONObj o( buf );
       
      >>>  BSONObj.valid() returns false signifying a corrupt BSON object.
                  if ( _objcheck && ! o.valid() ) {
                      cerr << "INVALID OBJECT - going try and pring out " << endl;
                      cerr << "size: " << size << endl;
                      BSONObjIterator i(o);
                      while ( i.more() ) {
                          BSONElement e = i.next();
                          try {
      >>>  e.validate() does not throw an exception and the "NEXT ONE" message is not printed.
                              e.validate();
                          }
                          catch ( ... ) {
                              cerr << "\t\t NEXT ONE IS INVALID" << endl;
                          }
                          cerr << "\t name : " << e.fieldName() << " " << e.type() << endl;
       
      >>>  An assertion is triggered on printing "e" (a BSONElement) to standard error. 
                          cerr << "\t " << e << endl;
                      }
                  }

      When we have a corrupt BSONElement, BSONElement.validate() should recognize and throw an exception.

      Attachments

        Issue Links

          Activity

            People

              mathias@mongodb.com Mathias Stearn
              james.wahlin@mongodb.com James Wahlin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: