@@ -86,7 +86,7 @@ mongoc_uri_append_host (mongoc_uri_t *uri, const char *host, uint16_t port)
86
86
}
87
87
88
88
link_ = (mongoc_host_list_t * ) bson_malloc0 (sizeof * link_ );
89
- mongoc_lowercase ( host , link_ -> host );
89
+ bson_strncpy ( link_ -> host , host , sizeof link_ -> host );
90
90
if (strchr (host , ':' )) {
91
91
bson_snprintf (link_ -> host_and_port ,
92
92
sizeof link_ -> host_and_port ,
@@ -262,6 +262,7 @@ mongoc_uri_parse_host6 (mongoc_uri_t *uri, const char *str)
262
262
return false;
263
263
}
264
264
265
+ mongoc_lowercase (hostname , hostname );
265
266
r = mongoc_uri_append_host (uri , hostname , port );
266
267
bson_free (hostname );
267
268
@@ -270,7 +271,7 @@ mongoc_uri_parse_host6 (mongoc_uri_t *uri, const char *str)
270
271
271
272
272
273
bool
273
- mongoc_uri_parse_host (mongoc_uri_t * uri , const char * str )
274
+ mongoc_uri_parse_host (mongoc_uri_t * uri , const char * str , bool downcase )
274
275
{
275
276
uint16_t port ;
276
277
const char * end_host ;
@@ -310,6 +311,10 @@ mongoc_uri_parse_host (mongoc_uri_t *uri, const char *str)
310
311
return false;
311
312
}
312
313
314
+ if (downcase ) {
315
+ mongoc_lowercase (hostname , hostname );
316
+ }
317
+
313
318
r = mongoc_uri_append_host (uri , hostname , port );
314
319
bson_free (hostname );
315
320
@@ -341,11 +346,11 @@ mongoc_uri_parse_hosts (mongoc_uri_t *uri, const char *str, const char **end)
341
346
*/
342
347
343
348
again :
344
- if (((* str == '/' ) && (sock = strstr (str , ".sock" ))) &&
349
+ if (((! strncmp ( str , "%2F" , 3 ) ) && (sock = strstr (str , ".sock" ))) &&
345
350
(!(tmp = strstr (str , "," )) || (tmp > sock )) &&
346
351
(!(tmp = strstr (str , "?" )) || (tmp > sock ))) {
347
352
s = bson_strndup (str , sock + 5 - str );
348
- if (!mongoc_uri_parse_host (uri , s )) {
353
+ if (!mongoc_uri_parse_host (uri , s , false /* downcase */ )) {
349
354
bson_free (s );
350
355
return false;
351
356
}
@@ -358,7 +363,7 @@ mongoc_uri_parse_hosts (mongoc_uri_t *uri, const char *str, const char **end)
358
363
}
359
364
* end = str ;
360
365
} else if ((s = scan_to_unichar (str , ',' , "/" , & end_hostport ))) {
361
- if (!mongoc_uri_parse_host (uri , s )) {
366
+ if (!mongoc_uri_parse_host (uri , s , true /* downcase */ )) {
362
367
bson_free (s );
363
368
return false;
364
369
}
@@ -368,15 +373,15 @@ mongoc_uri_parse_hosts (mongoc_uri_t *uri, const char *str, const char **end)
368
373
goto again ;
369
374
} else if ((s = scan_to_unichar (str , '/' , "" , & end_hostport )) ||
370
375
(s = scan_to_unichar (str , '?' , "" , & end_hostport ))) {
371
- if (!mongoc_uri_parse_host (uri , s )) {
376
+ if (!mongoc_uri_parse_host (uri , s , true /* downcase */ )) {
372
377
bson_free (s );
373
378
return false;
374
379
}
375
380
bson_free (s );
376
381
* end = end_hostport ;
377
382
return true;
378
383
} else if (* str ) {
379
- if (!mongoc_uri_parse_host (uri , str )) {
384
+ if (!mongoc_uri_parse_host (uri , str , true /* downcase */ )) {
380
385
return false;
381
386
}
382
387
* end = str + strlen (str );
0 commit comments