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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • None
    • None
    • None
    • Fully Compatible
    • ALL
    • 130

    Description

      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.

       

      Attachments

        Activity

          People

            ian.boros@mongodb.com Ian Boros
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: