From 2a4aae196f342297284b32e89b80301b679c8c23 Mon Sep 17 00:00:00 2001 From: Xavrax Date: Wed, 22 Nov 2023 10:22:31 +0100 Subject: [PATCH 1/4] return message on decryption fail --- core/pubnub_ccore_pubsub.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index f1e01cfa..2c92ad32 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -122,8 +122,8 @@ char const* pbcc_get_msg(struct pbcc_context* pb) if (NULL != pb->crypto_module) { char* trimmed = (char*)malloc(strlen(rslt) + 1); // same length as rslt if (NULL == trimmed) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Dropping message!\n", pb); - return NULL; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Returning original message!\n", pb); + return rslt; } sprintf(trimmed, "%s", rslt); @@ -133,20 +133,20 @@ char const* pbcc_get_msg(struct pbcc_context* pb) free(trimmed); if (NULL == encrypted.ptr) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - base64 decoding failed. Dropping message!\n", pb); - return NULL; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - base64 decoding failed. Returning original message!\n", pb); + return rslt; } pubnub_bymebl_t rslt_block = pb->crypto_module->decrypt(pb->crypto_module, encrypted); free(encrypted.ptr); if (NULL == rslt_block.ptr) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - decryption failed. Dropping message!\n", pb); - return NULL; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - decryption failed. Returning original message!\n", pb); + return rslt; } if (pb->decrypted_message_count >= PUBNUB_MAX_DECRYPTED_MESSAGES) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Dropping message!\n", pb); - return NULL; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb); + return rslt; } pb->decrypted_messages[pb->decrypted_message_count] = rslt_block.ptr; From bce16c905fe1bdece0b18e31a8e40b010f5c0651 Mon Sep 17 00:00:00 2001 From: Xavrax Date: Wed, 22 Nov 2023 10:23:36 +0100 Subject: [PATCH 2/4] error to warn --- core/pubnub_ccore_pubsub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index 2c92ad32..e27979a8 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -122,7 +122,7 @@ char const* pbcc_get_msg(struct pbcc_context* pb) if (NULL != pb->crypto_module) { char* trimmed = (char*)malloc(strlen(rslt) + 1); // same length as rslt if (NULL == trimmed) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Returning original message!\n", pb); + PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Returning original message!\n", pb); return rslt; } sprintf(trimmed, "%s", rslt); @@ -133,19 +133,19 @@ char const* pbcc_get_msg(struct pbcc_context* pb) free(trimmed); if (NULL == encrypted.ptr) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - base64 decoding failed. Returning original message!\n", pb); + PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - base64 decoding failed. Returning original message!\n", pb); return rslt; } pubnub_bymebl_t rslt_block = pb->crypto_module->decrypt(pb->crypto_module, encrypted); free(encrypted.ptr); if (NULL == rslt_block.ptr) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - decryption failed. Returning original message!\n", pb); + PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - decryption failed. Returning original message!\n", pb); return rslt; } if (pb->decrypted_message_count >= PUBNUB_MAX_DECRYPTED_MESSAGES) { - PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb); + PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb); return rslt; } From 2ddda22c6ad025ac9c957df5dbac9241f1bf8ab8 Mon Sep 17 00:00:00 2001 From: Xavrax Date: Thu, 23 Nov 2023 14:08:30 +0100 Subject: [PATCH 3/4] warns and errors --- core/pubnub_ccore_pubsub.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/pubnub_ccore_pubsub.c b/core/pubnub_ccore_pubsub.c index e27979a8..b14d2057 100644 --- a/core/pubnub_ccore_pubsub.c +++ b/core/pubnub_ccore_pubsub.c @@ -122,8 +122,8 @@ char const* pbcc_get_msg(struct pbcc_context* pb) if (NULL != pb->crypto_module) { char* trimmed = (char*)malloc(strlen(rslt) + 1); // same length as rslt if (NULL == trimmed) { - PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Returning original message!\n", pb); - return rslt; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - failed to allocate memory for trimmed string. Returning original message!\n", pb); + return NULL; } sprintf(trimmed, "%s", rslt); @@ -145,8 +145,8 @@ char const* pbcc_get_msg(struct pbcc_context* pb) } if (pb->decrypted_message_count >= PUBNUB_MAX_DECRYPTED_MESSAGES) { - PUBNUB_LOG_WARNING("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb); - return rslt; + PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb); + return NULL; } pb->decrypted_messages[pb->decrypted_message_count] = rslt_block.ptr; From c00e9625a55ee1ba1d4437f13aa82fb7c250802a Mon Sep 17 00:00:00 2001 From: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:29:00 +0000 Subject: [PATCH 4/4] PubNub SDK v4.7.1 release. --- .pubnub.yml | 21 +++++++++++++-------- CHANGELOG.md | 6 ++++++ core/pubnub_version_internal.h | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index c987cc00..0893684a 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,8 +1,13 @@ name: c-core schema: 1 -version: "4.7.0" +version: "4.7.1" scm: github.com/pubnub/c-core changelog: + - date: 2023-11-23 + version: v4.7.1 + changes: + - type: bug + text: "Handle unencrypted message while getting messages with crypto." - date: 2023-11-20 version: v4.7.0 changes: @@ -763,7 +768,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -829,7 +834,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -895,7 +900,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -957,7 +962,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -1018,7 +1023,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -1074,7 +1079,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" @@ -1127,7 +1132,7 @@ sdks: distribution-type: source code distribution-repository: GitHub release package-name: C-Core - location: https://github.com/pubnub/c-core/releases/tag/v4.7.0 + location: https://github.com/pubnub/c-core/releases/tag/v4.7.1 requires: - name: "miniz" diff --git a/CHANGELOG.md b/CHANGELOG.md index 03bf4650..407f69c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.7.1 +November 23 2023 + +#### Fixed +- Handle unencrypted message while getting messages with crypto. + ## v4.7.0 November 20 2023 diff --git a/core/pubnub_version_internal.h b/core/pubnub_version_internal.h index dd6aaf6d..b8adf3e4 100644 --- a/core/pubnub_version_internal.h +++ b/core/pubnub_version_internal.h @@ -3,7 +3,7 @@ #define INC_PUBNUB_VERSION_INTERNAL -#define PUBNUB_SDK_VERSION "4.7.0" +#define PUBNUB_SDK_VERSION "4.7.1" #endif /* !defined INC_PUBNUB_VERSION_INTERNAL */