Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-8

bson_append_binary produces bogus data

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 0.2
    • None
    • None
    • None

    Description

      The following lines:

      const int size = 4+1+len;
      if ( ! bson_append_estart( b , bson_bindata , name , size ) ) return 0;
      bson_append32(b, &size);

      Should be replaced with:

      if ( ! bson_append_estart( b , bson_bindata , name , 4+1+len ) ) return 0;
      bson_append32(b, &len);

      Because the first 32-bit of a binary must only account for the size of the binary data itself.

      BTW, it would be nice to have a way to append an binary array (that is, bindata subtype 2, see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary) without preencoding the "str" argument of bson_append_binary.

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            rgl Rui Lopes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: