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

Remove BSONElement::validate()

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.5
    • Affects Version/s: 2.4.8
    • Component/s: None
    • None
    • Minor Change
    • ALL

      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.

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

              Created:
              Updated:
              Resolved: