diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-10-11 13:49:08 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-10-11 13:49:08 +0000 |
commit | 8b692d8326a1548a7dbbd2cecee9ece6aa60473a (patch) | |
tree | 351fae07f93e6246cf9df7c7d1a3c6c77e7b6dc5 | |
parent | 395cfeea94febb5280ea57027e8a8a3c7c3f9291 (diff) | |
download | samba-8b692d8326a1548a7dbbd2cecee9ece6aa60473a.tar.gz samba-8b692d8326a1548a7dbbd2cecee9ece6aa60473a.tar.xz samba-8b692d8326a1548a7dbbd2cecee9ece6aa60473a.zip |
improve the error handling in the ASN1 code a bit
-rw-r--r-- | source/libsmb/clikrb5.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/source/libsmb/clikrb5.c b/source/libsmb/clikrb5.c index fb442f7f095..b4847e4c2aa 100644 --- a/source/libsmb/clikrb5.c +++ b/source/libsmb/clikrb5.c @@ -27,8 +27,6 @@ #define OID_SPNEGO "1 3 6 1 5 5 2" #define OID_KERBEROS5 "1 2 840 113554 1 2 2" -#define CHECK_CALL(x) if (! x) goto failed - /* we can't use krb5_mk_req because w2k wants the service to be in a particular format */ @@ -141,16 +139,16 @@ ASN1_DATA spnego_gen_negTokenInit(uint8 guid[16], memset(&data, 0, sizeof(data)); - CHECK_CALL(asn1_write(&data, guid, 16)); - CHECK_CALL(asn1_push_tag(&data,ASN1_APPLICATION(0))); - CHECK_CALL(asn1_write_OID(&data,OID_SPNEGO)); - CHECK_CALL(asn1_push_tag(&data,ASN1_CONTEXT(0))); - CHECK_CALL(asn1_push_tag(&data,ASN1_SEQUENCE(0))); + asn1_write(&data, guid, 16); + asn1_push_tag(&data,ASN1_APPLICATION(0)); + asn1_write_OID(&data,OID_SPNEGO); + asn1_push_tag(&data,ASN1_CONTEXT(0)); + asn1_push_tag(&data,ASN1_SEQUENCE(0)); - CHECK_CALL(asn1_push_tag(&data,ASN1_CONTEXT(0))); - CHECK_CALL(asn1_push_tag(&data,ASN1_SEQUENCE(0))); + asn1_push_tag(&data,ASN1_CONTEXT(0)); + asn1_push_tag(&data,ASN1_SEQUENCE(0)); for (i=0; OIDs[i]; i++) { - CHECK_CALL(asn1_write_OID(&data,OIDs[i])); + asn1_write_OID(&data,OIDs[i]); } asn1_pop_tag(&data); asn1_pop_tag(&data); @@ -168,11 +166,11 @@ ASN1_DATA spnego_gen_negTokenInit(uint8 guid[16], asn1_pop_tag(&data); - return data; + if (data.has_error) { + DEBUG(1,("Failed to build negTokenInit at offset %d\n", (int)data.ofs)); + asn1_free(&data); + } -failed: - DEBUG(1,("Failed to build negTokenInit at offset %d\n", (int)data.ofs)); - asn1_free(&data); return data; } @@ -260,6 +258,11 @@ static ASN1_DATA gen_negTokenTarg(const char *OIDs[], ASN1_DATA blob) asn1_pop_tag(&data); + if (data.has_error) { + DEBUG(1,("Failed to build negTokenTarg at offset %d\n", (int)data.ofs)); + asn1_free(&data); + } + return data; } @@ -279,6 +282,11 @@ static ASN1_DATA spnego_gen_krb5_wrap(DATA_BLOB ticket) asn1_write(&data, ticket.data, ticket.length); asn1_pop_tag(&data); + if (data.has_error) { + DEBUG(1,("Failed to build krb5 wrapper at offset %d\n", (int)data.ofs)); + asn1_free(&data); + } + return data; } |