s3-spnego: Fix Bug #6815. Windows 2008 R2 SPNEGO negTokenTarg parsing failure.
authorGünther Deschner <gd@samba.org>
Thu, 15 Oct 2009 14:01:36 +0000 (16:01 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 20 Oct 2009 10:02:31 +0000 (12:02 +0200)
When parsing a SPNEGO session setup retry (falling back from KRB5 to NTLMSSP),
we failed to parse the ASN1_ENUMERATED negResult in the negTokenTarg, thus
failing spnego_parse_auth() completely.

Guenther

source3/Makefile.in
source3/libsmb/clispnego.c

index 1484e111d94dee50cc7e7f53aef5ce0f16be2f62..fb45056a96ab6023990b6b0359496497e113fbdd 100644 (file)
@@ -465,7 +465,7 @@ LIBCLI_LDAP_NDR_OBJ = ../libcli/ldap/ldap_ndr.o
 CLDAP_OBJ = libads/cldap.o $(LIBCLI_LDAP_MESSAGE_OBJ) $(LIBCLI_LDAP_NDR_OBJ)
 
 LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
-            libsmb/clikrb5.o libsmb/clispnego.o ../lib/util/asn1.o \
+            libsmb/clikrb5.o libsmb/clispnego.o libsmb/spnego.o ../lib/util/asn1.o \
             libsmb/clirap.o libsmb/clierror.o libsmb/climessage.o \
             libsmb/clireadwrite.o libsmb/clilist.o libsmb/cliprint.o \
             libsmb/clitrans.o libsmb/clisecdesc.o libsmb/clidgram.o \
index fb95d719259a5f2e54d68f11d43d2eb3ad636552..b531c3976ef061cbcc8124965732f0759ed4f4e1 100644 (file)
@@ -494,31 +494,28 @@ DATA_BLOB spnego_gen_auth(DATA_BLOB blob)
 */
 bool spnego_parse_auth(DATA_BLOB blob, DATA_BLOB *auth)
 {
-       ASN1_DATA *data;
+       SPNEGO_DATA token;
+       ssize_t len;
 
-       data = asn1_init(talloc_tos());
-       if (data == NULL) {
+       len = read_spnego_data(talloc_tos(), blob, &token);
+       if (len == -1) {
+               DEBUG(3,("spnego_parse_auth: read_spnego_data failed\n"));
                return false;
        }
 
-       asn1_load(data, blob);
-       asn1_start_tag(data, ASN1_CONTEXT(1));
-       asn1_start_tag(data, ASN1_SEQUENCE(0));
-       asn1_start_tag(data, ASN1_CONTEXT(2));
-       asn1_read_OctetString(data, NULL, auth);
-       asn1_end_tag(data);
-       asn1_end_tag(data);
-       asn1_end_tag(data);
-
-       if (data->has_error) {
-               DEBUG(3,("spnego_parse_auth failed at %d\n", (int)data->ofs));
-               data_blob_free(auth);
-               asn1_free(data);
-               return False;
+       if (token.type != SPNEGO_NEG_TOKEN_TARG) {
+               DEBUG(3,("spnego_parse_auth: wrong token type: %d\n",
+                       token.type));
+               free_spnego_data(&token);
+               return false;
        }
 
-       asn1_free(data);
-       return True;
+       *auth = data_blob_talloc(talloc_tos(),
+                                token.negTokenTarg.responseToken.data,
+                                token.negTokenTarg.responseToken.length);
+       free_spnego_data(&token);
+
+       return true;
 }
 
 /*