@@ -559,6 +559,18 @@ static void tpm2_policy_parse_policy_list_double_call(void **state) {
559559 assert_memory_equal (policy_list .digests [3 ].buffer , sha256_digest_2 , sizeof (sha256_digest_2 ));
560560}
561561
562+ static void tpm2_policy_parse_policy_list_toomany (void * * state ) {
563+ UNUSED (state );
564+
565+ TPML_DIGEST policy_list = { 0 };
566+ char str [] = "sha256:testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,"
567+ "testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,"
568+ "testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,"
569+ "testpolicy.sha256,testpolicy.sha256,testpolicy.sha256,testpolicy.sha256" ;
570+ bool res = tpm2_policy_parse_policy_list (str , & policy_list );
571+ assert_false (res );
572+ }
573+
562574/* link required symbol, but tpm2_tool.c declares it AND main, which
563575 * we have a main below for cmocka tests.
564576 */
@@ -572,6 +584,7 @@ int main(int argc, char *argv[]) {
572584 cmocka_unit_test (test_tpm2_policy_build_pcr_good ),
573585 cmocka_unit_test (tpm2_policy_parse_policy_list_good ),
574586 cmocka_unit_test (tpm2_policy_parse_policy_list_double_call ),
587+ cmocka_unit_test (tpm2_policy_parse_policy_list_toomany ),
575588 cmocka_unit_test_setup_teardown (test_tpm2_policy_build_pcr_file_good ,
576589 test_setup , test_teardown ),
577590 cmocka_unit_test_setup_teardown (test_tpm2_policy_build_pcr_file_bad_size ,
0 commit comments