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

URI parsing does not validate out-of-range port numbers

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • TBD
    • Affects Version/s: 1.1.0
    • Component/s: None
    • Labels:
      None

      In our test suite, the base URI in standalone server tests is "mongodb://192.168.112.10:2000". If we improperly concatenate this string and create an invalid port (e.g. 2000999), mongoc_uri_parse_host() still attempts to parse it as an unsigned 16-bit integer:

      sscanf (end_host, "%hu", &port);
      

      The end result is an exception when the driver cannot connect to a server on port 34919. Would it make more sense to attempt to validate the port and return an error during parsing?

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: