Unchecked conversion from double to int in mongo shell may result in UB

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • 130
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The following line converts a double (from user input) to int without any kind of bounds check. If the double cannot be represented by an int, this is undefined behavior.

       

      Example:

      db.c.find(BinData(18446744073709552000, 'AAA=')) 

      The BinData subtype is only one byte, so we should just ensure the value is between 0 and 255 before doing the cast.

       

            Assignee:
            Ian Boros
            Reporter:
            Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: