@@ -144,16 +144,20 @@ jwt_parsing_helper(const char *jwt_string)
144144{
145145 fprintf (stderr, " Parsing JWT from string: %s\n " , jwt_string);
146146 bool resp;
147- json_error_t jerr = {};
148- size_t pt_ct = strlen (jwt_string);
149- struct jwt *jwt = parse_jwt (json_loadb (jwt_string, pt_ct, 0 , &jerr));
147+ json_error_t jerr = {};
148+ size_t pt_ct = strlen (jwt_string);
149+ struct json_t *const jwk_json = json_loadb (jwt_string, pt_ct, 0 , &jerr);
150+ if (!jwk_json) {
151+ return false ;
152+ }
150153
151- if ( jwt) {
152- resp = jwt_validate ( jwt);
153- } else {
154- resp = false ;
154+ struct jwt *jwt = parse_jwt (jwk_json);
155+ if (! jwt) {
156+ json_decref (jwk_json);
157+ return false ;
155158 }
156159
160+ resp = jwt_validate (jwt);
157161 jwt_delete (jwt);
158162 return resp;
159163}
@@ -601,7 +605,6 @@ TEST_CASE("6", "[AudTests]")
601605 json_t *raw = json_loads (" {\" aud\" : \" tester\" }" , 0 , err);
602606 json_t *aud = json_object_get (raw, " aud" );
603607 REQUIRE (jwt_check_aud (aud, " tester" ));
604- json_decref (aud);
605608 json_decref (raw);
606609 }
607610
@@ -610,7 +613,6 @@ TEST_CASE("6", "[AudTests]")
610613 json_t *raw = json_loads (" {\" aud\" : [ \" foo\" , \" bar\" , \" tester\" ]}" , 0 , err);
611614 json_t *aud = json_object_get (raw, " aud" );
612615 REQUIRE (jwt_check_aud (aud, " tester" ));
613- json_decref (aud);
614616 json_decref (raw);
615617 }
616618
@@ -619,7 +621,6 @@ TEST_CASE("6", "[AudTests]")
619621 json_t *raw = json_loads (" {\" aud\" : \" foo\" }" , 0 , err);
620622 json_t *aud = json_object_get (raw, " aud" );
621623 REQUIRE (!jwt_check_aud (aud, " tester" ));
622- json_decref (aud);
623624 json_decref (raw);
624625 }
625626
@@ -628,7 +629,6 @@ TEST_CASE("6", "[AudTests]")
628629 json_t *raw = json_loads (" {\" aud\" : [\" foo\" , \" bar\" , \" foobar\" ]}" , 0 , err);
629630 json_t *aud = json_object_get (raw, " aud" );
630631 REQUIRE (!jwt_check_aud (aud, " tester" ));
631- json_decref (aud);
632632 json_decref (raw);
633633 }
634634
@@ -637,7 +637,6 @@ TEST_CASE("6", "[AudTests]")
637637 json_t *raw = json_loads (" {\" aud\" : 1}" , 0 , err);
638638 json_t *aud = json_object_get (raw, " aud" );
639639 REQUIRE (!jwt_check_aud (aud, " tester" ));
640- json_decref (aud);
641640 json_decref (raw);
642641 }
643642
@@ -646,7 +645,6 @@ TEST_CASE("6", "[AudTests]")
646645 json_t *raw = json_loads (" {\" aud\" : [1, \" foo\" , \" bar\" , \" tester\" ]}" , 0 , err);
647646 json_t *aud = json_object_get (raw, " aud" );
648647 REQUIRE (jwt_check_aud (aud, " tester" ));
649- json_decref (aud);
650648 json_decref (raw);
651649 }
652650
@@ -655,7 +653,6 @@ TEST_CASE("6", "[AudTests]")
655653 json_t *raw = json_loads (" {\" aud\" : \" TESTer\" }" , 0 , err);
656654 json_t *aud = json_object_get (raw, " aud" );
657655 REQUIRE (!jwt_check_aud (aud, " tester" ));
658- json_decref (aud);
659656 json_decref (raw);
660657 }
661658
@@ -664,7 +661,6 @@ TEST_CASE("6", "[AudTests]")
664661 json_t *raw = json_loads (" {\" aud\" : [1, \" foo\" , \" bar\" , \" Tester\" ]}" , 0 , err);
665662 json_t *aud = json_object_get (raw, " aud" );
666663 REQUIRE (!jwt_check_aud (aud, " tester" ));
667- json_decref (aud);
668664 json_decref (raw);
669665 }
670666
@@ -699,14 +695,17 @@ jws_validation_helper(const char *url, const char *package, struct config *cfg)
699695 if (!jws) {
700696 return false ;
701697 }
698+ fprintf (stderr, " jws: %p\n " , jws);
699+ fflush (stderr);
702700 struct jwt *jwt = validate_jws (jws, cfg, uri_strip, strip_ct);
703- if (jwt) {
704- jwt_delete (jwt);
705- cjose_jws_release (jws);
706- return true ;
707- }
708701 cjose_jws_release (jws);
709- return false ;
702+ fprintf (stderr, " jws: %p\n " , jws);
703+ fflush (stderr);
704+ if (!jwt) {
705+ return false ;
706+ }
707+ jwt_delete (jwt);
708+ return true ;
710709}
711710
712711TEST_CASE (" 8" , " [TestsWithConfig]" )
0 commit comments