[CDRIVER-2155] Bug in unreleased code: Client pool cannot connect with IPv6 address like "[::1]" Created: 09/May/17  Updated: 28/Oct/23  Resolved: 16/May/17

Status: Closed
Project: C Driver
Component/s: libmongoc, network
Affects Version/s: None
Fix Version/s: 1.7.0

Type: Bug Priority: Minor - P4
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Bug in unreleased code, introduced on master during 1.7 development. This bug does not affect released versions.

The driver correctly strips the "[" and "]" characters from the host in a URI like "mongodb://[::1]" before calling getaddrinfo on the host in mongoc_topology_scanner_node_connect_tcp(). In single-client mode, that is the only getaddrinfo call; the connection established by the topology scanner is also used for application operations.

In pooled mode, however, there is a second path for establishing connections for application operations, in mongoc_client_connect_tcp. This second path does not strip "[" and "]" from the hostname, and so it calls getaddrinfo on a misformatted string like "[::1]" instead of the intended "::1".

Connecting to "mongodb://[::1]" in pooled mode fails, therefore, with an error like "Failed to resolve [::1]".



 Comments   
Comment by Githook User [ 16/May/17 ]

Author:

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

Message: CDRIVER-2155 fix IPv6 parsing in pooled mode
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/d1f6383ee83e0c7d97978b26fc192d8adadf4d0a

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