Skip to content

Commit

Permalink
Fix possible NULL pointer dereference in find_by_thp()
Browse files Browse the repository at this point in the history
jwk_thumbprint() might return NULL, so let's make sure we handle that
case.

Issue pointed out by gcc static analyzer.
  • Loading branch information
sergio-correia committed May 20, 2021
1 parent 3d770c6 commit 262d98f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/keys.c
Original file line number Diff line number Diff line change
@@ -263,7 +263,7 @@ find_by_thp(struct tang_keys_info* tki, const char* target)
json_array_foreach(keys, idx, jwk) {
for (int i = 0; hashes[i]; i++) {
__attribute__ ((__cleanup__(cleanup_str))) char* thumbprint = jwk_thumbprint(jwk, hashes[i]);
if (strcmp(thumbprint, target) != 0) {
if (!thumbprint || strcmp(thumbprint, target) != 0) {
continue;
}

0 comments on commit 262d98f

Please sign in to comment.