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

Max URI set to only 64 chars

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: None
    • Component/s: uri
    • None

      When attempting to connect to a dns name longer then 64 chars, mongoc will erroneously fail preemptively because the hostname is longer then HOST_NAME_MAX.

      ./mongoc-ping "mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me"
      2017/02/10 10:03:35.0051: [ 8490]:    ERROR:       mongoc: Hostname provided in URI is too long, max is 64 chars
      Invalid hostname or port: mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me
      

      The hostname works just fine, as dns names can be up to 255 chars.
      So removing this limitation, and it works fine:

      git diff
      diff --git a/src/mongoc/mongoc-host-list.h b/src/mongoc/mongoc-host-list.h
      index de1689d..6e1397e 100644
      --- a/src/mongoc/mongoc-host-list.h
      +++ b/src/mongoc/mongoc-host-list.h
      @@ -34,7 +34,7 @@ BSON_BEGIN_DECLS
       #define BSON_HOST_NAME_MAX 255
       #endif
       #else
      -#define BSON_HOST_NAME_MAX HOST_NAME_MAX
      +#define BSON_HOST_NAME_MAX 255
       #endif
       
       
       bjori@TaylorSwift  ~/Sources/mongoc   master ●  ./mongoc-ping "mongodb://abcdefghijklmnopqrstuvwxyz.1234567890.ABCDEFGHIJKLMNOPQRSTUVWXYZ.vcap.me"
      { "ok" : 1.0 }
      

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: