svn rev #25744: trunk/src/ lib/krb5/asn.1/ tests/asn.1/
ghudson@MIT.EDU
ghudson at MIT.EDU
Wed Mar 7 19:37:47 EST 2012
http://src.mit.edu/fisheye/changelog/krb5/?cs=25744
Commit By: ghudson
Log Message:
ticket: 7100
Properly decode etype-info2 with no salt
The data-driven decoder for etype-info2 was neglecting to call
init_no_salt() when no salt is present in the encoding. Add in the
missing call. Also add decode test cases for etype-info2, which would
have caught this if they weren't missing.
Changed Files:
U trunk/src/lib/krb5/asn.1/asn1_k_encode.c
U trunk/src/tests/asn.1/krb5_decode_test.c
Modified: trunk/src/lib/krb5/asn.1/asn1_k_encode.c
===================================================================
--- trunk/src/lib/krb5/asn.1/asn1_k_encode.c 2012-03-08 00:37:44 UTC (rev 25743)
+++ trunk/src/lib/krb5/asn.1/asn1_k_encode.c 2012-03-08 00:37:47 UTC (rev 25744)
@@ -602,7 +602,8 @@
/* First field is the same as etype-info. */
DEFCNFIELD(etype_info2_1_def, krb5_etype_info_entry, salt, length, 1,
u_generalstring);
-DEFOPTIONALTYPE(etype_info2_1, is_salt_present, NULL, etype_info2_1_def);
+DEFOPTIONALTYPE(etype_info2_1, is_salt_present, init_no_salt,
+ etype_info2_1_def);
DEFFIELD(etype_info2_2, krb5_etype_info_entry, s2kparams, 2, opt_ostring_data);
static const struct atype_info *etype_info2_entry_fields[] = {
&k5_atype_etype_info_0, &k5_atype_etype_info2_1, &k5_atype_etype_info2_2
Modified: trunk/src/tests/asn.1/krb5_decode_test.c
===================================================================
--- trunk/src/tests/asn.1/krb5_decode_test.c 2012-03-08 00:37:44 UTC (rev 25743)
+++ trunk/src/tests/asn.1/krb5_decode_test.c 2012-03-08 00:37:47 UTC (rev 25744)
@@ -859,6 +859,46 @@
}
/****************************************************************/
+ /* decode_etype_info2 */
+ {
+ krb5_etype_info ref, var;
+
+ ktest_make_sample_etype_info2(&ref);
+ retval = krb5_data_hex_parse(&code,"30 51 30 1E A0 03 02 01 00 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 A2 08 04 06 73 32 6B 3A 20 30 30 0F A0 03 02 01 01 A2 08 04 06 73 32 6B 3A 20 31 30 1E A0 03 02 01 02 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 32 A2 08 04 06 73 32 6B 3A 20 32");
+ if (retval) {
+ com_err("krb5_decode_test", retval, "while parsing etype_info2");
+ exit(1);
+ }
+ retval = decode_krb5_etype_info2(&code,&var);
+ if (retval) {
+ com_err("krb5_decode_test", retval, "while decoding etype_info2");
+ }
+ test(ktest_equal_etype_info(ref,var),"etype_info2\n");
+
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info_entry(ref[2]); ref[2] = 0;
+ ktest_destroy_etype_info_entry(ref[1]); ref[1] = 0;
+ krb5_free_data_contents(test_context, &code);
+
+ retval = krb5_data_hex_parse(&code,"30 20 30 1E A0 03 02 01 00 A1 0D 1B 0B 4D 6F 72 74 6F 6E 27 73 20 23 30 A2 08 04 06 73 32 6B 3A 20 30");
+ if (retval) {
+ com_err("krb5_decode_test", retval,
+ "while parsing etype_info2 (only one)");
+ exit(1);
+ }
+ retval = decode_krb5_etype_info2(&code,&var);
+ if (retval) {
+ com_err("krb5_decode_test", retval,
+ "while decoding etype_info2 (only one)");
+ }
+ test(ktest_equal_etype_info(ref,var),"etype_info2 (only one)\n");
+
+ krb5_free_data_contents(test_context, &code);
+ ktest_destroy_etype_info(var);
+ ktest_destroy_etype_info(ref);
+ }
+
+ /****************************************************************/
/* decode_pa_enc_ts */
{
setup(krb5_pa_enc_ts,ktest_make_sample_pa_enc_ts);
More information about the cvs-krb5
mailing list