~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/lib/krb5/os/dnssrv.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2009-05-07 16:16:34 UTC
  • mfrom: (13.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090507161634-xqyk0s9na0le4flj
Tags: 1.7dfsg~beta1-4
When  decrypting the TGS response fails with the subkey, try with the
session key to work around Heimdal bug, Closes: #527353 

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
                             struct srv_dns_entry **answers)
61
61
{
62
62
    const unsigned char *p = NULL, *base = NULL;
63
 
    char host[MAXDNAME], *h;
64
 
    int size, ret, rdlen, nlen;
 
63
    char host[MAXDNAME];
 
64
    int size, ret, rdlen, nlen, len;
65
65
    unsigned short priority, weight, port;
66
66
    struct krb5int_dns_state *ds = NULL;
 
67
    struct k5buf buf;
67
68
 
68
69
    struct srv_dns_entry *head = NULL;
69
70
    struct srv_dns_entry *srv = NULL, *entry = NULL;
81
82
 
82
83
    if (memchr(realm->data, 0, realm->length))
83
84
        return 0;
84
 
    if ( strlen(service) + strlen(protocol) + realm->length + 6 
85
 
         > MAXDNAME )
86
 
        return 0;
87
 
    sprintf(host, "%s.%s.%.*s", service, protocol, (int) realm->length,
88
 
            realm->data);
 
85
    krb5int_buf_init_fixed(&buf, host, sizeof(host));
 
86
    krb5int_buf_add_fmt(&buf, "%s.%s.", service, protocol);
 
87
    krb5int_buf_add_len(&buf, realm->data, realm->length);
89
88
 
90
89
    /* Realm names don't (normally) end with ".", but if the query
91
90
       doesn't end with "." and doesn't get an answer as is, the
96
95
       a search on the prefix alone then the intention is to allow
97
96
       the local domain or domain search lists to be expanded.  */
98
97
 
99
 
    h = host + strlen (host);
100
 
    if ((h[-1] != '.') && ((h - host + 1) < sizeof(host)))
101
 
        strcpy (h, ".");
 
98
    len = krb5int_buf_len(&buf);
 
99
    if (len > 0 && host[len - 1] != '.')
 
100
        krb5int_buf_add(&buf, ".");
 
101
 
 
102
    if (krb5int_buf_data(&buf) == NULL)
 
103
        return 0;
102
104
 
103
105
#ifdef TEST
104
106
    fprintf (stderr, "sending DNS SRV query for %s\n", host);
142
144
        srv->port = port;
143
145
        /* The returned names are fully qualified.  Don't let the
144
146
           local resolver code do domain search path stuff.  */
145
 
        if (strlen(host) + 2 < sizeof(host))
146
 
            strcat(host, ".");
147
 
        srv->host = strdup(host);
148
 
        if (srv->host == NULL) {
 
147
        if (asprintf(&srv->host, "%s.", host) < 0) {
149
148
            free(srv);
150
149
            goto out;
151
150
        }