[CDRIVER-2789] Occasional crash with mongodb+srv URI on Windows Created: 06/Aug/18  Updated: 28/Oct/23  Resolved: 08/Aug/18

Status: Closed
Project: C Driver
Component/s: network
Affects Version/s: 1.9.0
Fix Version/s: 1.13.0

Type: Bug Priority: Major - P3
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

Issue Links:
Related
related to CDRIVER-3628 Non TXT/SRV records returned by res_n... Closed

 Description   

Reported by Jeroenooms. On his particular Windows networking setup, when the C Driver makes a TXT query for the address specified in a mongodb+srv URI, it receives multiple responses that are not TXT records; I've observed A records in the results, maybe there are other record types. Apparently this is a behavior of the DnsQuery_UTF8 function we use on Windows. Since the C Driver assumes all responses to a TXT query are TXT records, and attempts to process them as TXT records, it reads an uninitialized field of the DNS_RECORD struct and crashes.

On Windows, the driver should check each record's type before trying to process it.



 Comments   
Comment by Jeroen Ooms [X] [ 08/Aug/18 ]

Thanks! Looks good. I have cherry-picked the patch in mongolite:

https://github.com/jeroen/mongolite/commit/ad82edb18c18e099f5da567f36e8bc553f0552b5

Comment by A. Jesse Jiryu Davis [ 08/Aug/18 ]

Jeroenooms could you try the latest code once again with your Windows system to make sure it fixes the crash?

Comment by Githook User [ 08/Aug/18 ]

Author:

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

Message: CDRIVER-2789 crash with mongodb+srv on windows
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/ab210dc6604220662bb0c0d9fa05807470c175b1

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