Skip to content

Commit

Permalink
Fixed #46. Improved stability by avoiding memory leak when decoding c…
Browse files Browse the repository at this point in the history
…laims with a claims count of 0. Preparing for Release 2.3.4 ...
  • Loading branch information
GlitchedPolygons committed Jul 31, 2024
1 parent a7afbfc commit bb1b07c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" ${CMAKE_MODULE_PATH})

set(L8W8JWT_MAJOR 2)
set(L8W8JWT_MINOR 3)
set(L8W8JWT_PATCH 3)
set(L8W8JWT_PATCH 4)
set(L8W8JWT_VERSION_STRING "${L8W8JWT_MAJOR}.${L8W8JWT_MINOR}.${L8W8JWT_PATCH}")

option(L8W8JWT_ENABLE_TESTS "Build l8w8jwt tests." OFF)
Expand Down
4 changes: 2 additions & 2 deletions include/l8w8jwt/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ extern "C" {
/**
* Current l8w8jwt version number.
*/
#define L8W8JWT_VERSION 233
#define L8W8JWT_VERSION 234

/**
* Current l8w8jwt version number (as a human-readable string).
*/
#define L8W8JWT_VERSION_STR "2.3.3"
#define L8W8JWT_VERSION_STR "2.3.4"

#if defined(_WIN32) && defined(L8W8JWT_DLL)
#ifdef L8W8JWT_BUILD_DLL
Expand Down
28 changes: 18 additions & 10 deletions src/claim.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,31 @@ extern "C" {

void l8w8jwt_free_claims(struct l8w8jwt_claim* claims, const size_t claims_count)
{
if (claims != NULL && claims_count > 0)
if (claims == NULL)
{
for (struct l8w8jwt_claim* claim = claims; claim < claims + claims_count; ++claim)
return;
}

for (struct l8w8jwt_claim* claim = claims; claim < claims + claims_count; ++claim)
{
if (claim == NULL)
{
if (claim == NULL)
continue;
continue;
}

mbedtls_platform_zeroize(claim->key, claim->key_length);
mbedtls_platform_zeroize(claim->value, claim->value_length);
mbedtls_platform_zeroize(claim->key, claim->key_length);
mbedtls_platform_zeroize(claim->value, claim->value_length);

l8w8jwt_free(claim->key);
l8w8jwt_free(claim->value);
}
l8w8jwt_free(claim->key);
l8w8jwt_free(claim->value);
}

if (claims_count != 0)
{
mbedtls_platform_zeroize(claims, claims_count * sizeof(struct l8w8jwt_claim));
l8w8jwt_free(claims);
}

l8w8jwt_free(claims);
}

static inline void l8w8jwt_escape_claim_string(struct chillbuff* stringbuilder, const char* string, const size_t string_length)
Expand Down

0 comments on commit bb1b07c

Please sign in to comment.