Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unencrypted message while getting messages with crypto #170

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 6 additions & 6 deletions core/pubnub_ccore_pubsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. Dropping message!\n", pb);
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);
Expand All @@ -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. Dropping message!\n", pb);
return NULL;
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. Dropping message!\n", pb);
return NULL;
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. Dropping message!\n", pb);
PUBNUB_LOG_ERROR("pbcc_get_msg(pbcc=%p) - maximum number of decrypted messages reached. Returning original message!\n", pb);
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion core/pubnub_version_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Loading