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

HexData and BinData constructors do not check for out of range subtype

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • Hide
      > x = { "x" : HexData(-1,"") }
      { "x" : BinData(-1,"") }
      > db.foo.insert(x)
      > db.foo.find()
      { "_id" : ObjectId("51b60faec87bbbd9e8cbef2c"), "x" : BinData(255,"") }
      > db.foo.find(x)
      { "_id" : ObjectId("51b60faec87bbbd9e8cbef2c"), "x" : BinData(255,"") }
      > y = { "y" : HexData(256,"") }
      { "y" : BinData(256,"") }
      > db.foo.insert(y)
      > db.foo.find()
      { "_id" : ObjectId("51b60faec87bbbd9e8cbef2c"), "x" : BinData(255,"") }
      { "_id" : ObjectId("51b60fd5c87bbbd9e8cbef2d"), "y" : BinData(0,"") }
      > db.foo.find(y)
      { "_id" : ObjectId("51b60fd5c87bbbd9e8cbef2d"), "y" : BinData(0,"") }
      > db.foo.remove()
      > x = { "x" : BinData(-1,"") }
      { "x" : BinData(-1,"") }
      > db.foo.insert(x)
      > db.foo.find()
      { "_id" : ObjectId("51b6100cc87bbbd9e8cbef2e"), "x" : BinData(255,"") }
      > y = { "y" : BinData(256,"") }
      { "y" : BinData(256,"") }
      > db.foo.insert(y)
      > db.foo.find()
      { "_id" : ObjectId("51b6100cc87bbbd9e8cbef2e"), "x" : BinData(255,"") }
      { "_id" : ObjectId("51b61019c87bbbd9e8cbef2f"), "y" : BinData(0,"") }
      >
      
      Show
      > x = { "x" : HexData(-1,"") } { "x" : BinData(-1,"") } > db.foo.insert(x) > db.foo.find() { "_id" : ObjectId( "51b60faec87bbbd9e8cbef2c" ), "x" : BinData(255,"") } > db.foo.find(x) { "_id" : ObjectId( "51b60faec87bbbd9e8cbef2c" ), "x" : BinData(255,"") } > y = { "y" : HexData(256,"") } { "y" : BinData(256,"") } > db.foo.insert(y) > db.foo.find() { "_id" : ObjectId( "51b60faec87bbbd9e8cbef2c" ), "x" : BinData(255,"") } { "_id" : ObjectId( "51b60fd5c87bbbd9e8cbef2d" ), "y" : BinData(0,"") } > db.foo.find(y) { "_id" : ObjectId( "51b60fd5c87bbbd9e8cbef2d" ), "y" : BinData(0,"") } > db.foo.remove() > x = { "x" : BinData(-1,"") } { "x" : BinData(-1,"") } > db.foo.insert(x) > db.foo.find() { "_id" : ObjectId( "51b6100cc87bbbd9e8cbef2e" ), "x" : BinData(255,"") } > y = { "y" : BinData(256,"") } { "y" : BinData(256,"") } > db.foo.insert(y) > db.foo.find() { "_id" : ObjectId( "51b6100cc87bbbd9e8cbef2e" ), "x" : BinData(255,"") } { "_id" : ObjectId( "51b61019c87bbbd9e8cbef2f" ), "y" : BinData(0,"") } >

      The subtype of BinData and HexData is not checked to make sure it is in the range (0-255). Since BSON only has a single byte for the subtype, this does not round trip.

            Assignee:
            sverch Shaun Verch
            Reporter:
            sverch Shaun Verch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: