2000-08-31 Jeffrey Altman <jaltman@columbia.edu>
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 31 Aug 2000 07:47:04 +0000 (07:47 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 31 Aug 2000 07:47:04 +0000 (07:47 +0000)
        * locate_kdc.c: krb5_locate_srv_dns()
          Ensure that res_search() is called with a query string
          that is terminated by a '.' in order to disable the
          expansion of dns-search lists.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12641 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ChangeLog
src/lib/krb5/os/locate_kdc.c

index 1b445a685fd587ad00b684d8f3bbe93568c9e84d..afbfa4827a8d1727368ebefa6e56cc2e4cda5206 100644 (file)
@@ -1,3 +1,10 @@
+2000-08-31  Jeffrey Altman <jaltman@columbia.edu>
+
+        * locate_kdc.c: krb5_locate_srv_dns() 
+          Ensure that res_search() is called with a query string
+          that is terminated by a '.' in order to disable the
+          expansion of dns-search lists.
+
 2000-07-22  Tom Yu  <tlyu@mit.edu>
 
        * accessor.c: Add NEED_SOCKETS in order to get prototype for
index b7e6826b83562e01c98f9bf5dca6e36fbc59379c..25ab97b75dd8a9f9b91f594c4e69b7e3288f6f92 100644 (file)
@@ -359,7 +359,7 @@ krb5_locate_srv_dns(realm, service, protocol, addr_pp, naddrs)
        int priority;
        int weight;
        unsigned short port;
-       char *host;
+       char *host, *h;
     };
 
     struct srv_dns_entry *head = NULL;
@@ -383,12 +383,26 @@ krb5_locate_srv_dns(realm, service, protocol, addr_pp, naddrs)
      *
      */
 
-    if ( strlen(service) + strlen(protocol) + realm->length + 5 
+    if ( strlen(service) + strlen(protocol) + realm->length + 6 
          > MAX_DNS_NAMELEN )
         goto out;
     sprintf(host, "%s.%s.%.*s", service, protocol, realm->length,
            realm->data);
 
+    /* Realm names don't (normally) end with ".", but if the query
+    doesn't end with "." and doesn't get an answer as is, the
+    resolv code will try appending the local domain.  Since the
+    realm names are absolutes, let's stop that.  
+
+    But only if a name has been specified.  If we are performing
+    a search on the prefix alone then the intention is to allow
+    the local domain or domain search lists to be expanded.
+    */
+
+    h = host + strlen (host);
+    if ((h > host) && (h[-1] != '.') && ((h - host + 1) < sizeof(host)))
+        strcpy (h, ".");
+
     size = res_search(host, C_IN, T_SRV, answer.bytes, sizeof(answer.bytes));
 
     if (size < hdrsize)