Skip to content

Commit

Permalink
avoid memory leaks; remove union in oauth2_jose_jwks_provider_t
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Feb 10, 2025
1 parent 961f656 commit 18c86ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/jose_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ typedef oauth2_jose_jwk_list_t *(
typedef struct oauth2_jose_jwks_provider_t {
oauth2_jose_jwks_provider_type_t type;
oauth2_jose_jwks_resolve_cb_t *resolve;
union {
oauth2_uri_ctx_t *jwks_uri;
oauth2_jose_jwk_list_t *jwks;
struct {
char *alb_arn;
char *alb_base_url;
};
};
// struct oauth2_jose_jwks_provider_t *next;

// NB: avoid union because of compiler/memory issues

// OAUTH2_JOSE_JWKS_PROVIDER_JWKS_URI and
// OAUTH2_JOSE_JWKS_PROVIDER_ECKEY_URI
oauth2_uri_ctx_t *jwks_uri;

// OAUTH2_JOSE_JWKS_PROVIDER_LIST
oauth2_jose_jwk_list_t *jwks;

// OAUTH2_JOSE_JWKS_PROVIDER_AWS_ALB
char *alb_arn;
char *alb_base_url;
} oauth2_jose_jwks_provider_t;

_OAUTH2_CFG_CTX_TYPE_START(oauth2_jose_jwt_verify_ctx)
Expand Down
1 change: 1 addition & 0 deletions test/check_oauth2.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ START_TEST(test_oauth2_verify_aws_alb)
ck_assert_int_eq(rc, true);

oauth2_cfg_token_verify_free(_log, verify);
oauth2_mem_free(options);
oauth2_mem_free(url);
json_decref(json_payload);
}
Expand Down

0 comments on commit 18c86ac

Please sign in to comment.