[CDRIVER-576] URI parsing does not validate out-of-range port numbers Created: 12/Mar/15  Updated: 03/May/17  Resolved: 16/Mar/15

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.1.0
Fix Version/s: TBD

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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?



 Comments   
Comment by Githook User [ 24/Mar/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-576: Validate port number in URI.

Closes #202
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/2547749e4836761a50030a432ae77ab06507a117

Comment by Githook User [ 16/Mar/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-576: Validate port number in URI.

Closes #202
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/2547749e4836761a50030a432ae77ab06507a117

Comment by A. Jesse Jiryu Davis [ 15/Mar/15 ]

https://github.com/mongodb/mongo-c-driver/pull/202

Generated at Wed Feb 07 21:09:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.