s3-spnego: Fix Bug #6815. Windows 2008 R2 SPNEGO negTokenTarg parsing failure.
[ira/wip.git] / source3 / libsmb / clispnego.c
index 5d7e43d941f79f20c7f78f8c5f7ac3fd8e3ac92e..1103ef84b63bf965936929b5728eb50bd23ec9b6 100644 (file)
@@ -495,31 +495,24 @@ DATA_BLOB spnego_gen_auth(DATA_BLOB blob)
 */
 bool spnego_parse_auth(DATA_BLOB blob, DATA_BLOB *auth)
 {
 */
 bool spnego_parse_auth(DATA_BLOB blob, DATA_BLOB *auth)
 {
-       ASN1_DATA *data;
+       ssize_t len;
+       struct spnego_data token;
 
 
-       data = asn1_init(talloc_tos());
-       if (data == NULL) {
+       len = spnego_read_data(talloc_tos(), blob, &token);
+       if (len == -1) {
+               DEBUG(3,("spnego_parse_auth: spnego_read_data failed\n"));
                return false;
        }
 
                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, talloc_autofree_context(), 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));
+               return false;
        }
 
        }
 
-       asn1_free(data);
-       return True;
+       *auth = token.negTokenTarg.responseToken;
+
+       return true;
 }
 
 /*
 }
 
 /*