Skip to content

Fix crashes during unsubscribe. Fix pubnub_fetch_history with crypto module. #214

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

Merged
merged 3 commits into from
May 26, 2025
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
25 changes: 17 additions & 8 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
name: c-core
schema: 1
version: "5.0.0"
version: "5.0.1"
scm: github.com/pubnub/c-core
changelog:
- date: 2025-05-26
version: v5.0.1
changes:
- type: bug
text: "Fix crashes that could sometimes happen during unsubscribe due to calling `strlen` on null pointers."
- type: bug
text: "Fix `pubnub_fetch_history` function when used with crypto api. Change `PUBNUB_MAX_URL_PARAMS` to 12."
- type: bug
text: "Fix the issue that was causing memory fragmentation fault at the moment of the next automated heartbeat call."
- date: 2025-04-03
version: v5.0.0
changes:
Expand Down Expand Up @@ -936,7 +945,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1002,7 +1011,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1068,7 +1077,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1130,7 +1139,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1191,7 +1200,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1247,7 +1256,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down Expand Up @@ -1300,7 +1309,7 @@ sdks:
distribution-type: source code
distribution-repository: GitHub release
package-name: C-Core
location: https://github.com/pubnub/c-core/releases/tag/v5.0.0
location: https://github.com/pubnub/c-core/releases/tag/v5.0.1
requires:
-
name: "miniz"
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v5.0.1
May 26 2025

#### Fixed
- Fix crashes that could sometimes happen during unsubscribe due to calling `strlen` on null pointers.
- Fix `pubnub_fetch_history` function when used with crypto api. Change `PUBNUB_MAX_URL_PARAMS` to 12.
- Fix the issue that was causing memory fragmentation fault at the moment of the next automated heartbeat call.

## v5.0.0
April 03 2025

Expand Down
9 changes: 6 additions & 3 deletions core/pbauto_heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ static int copy_context_settings(pubnub_t* pb_clone, pubnub_t const* pb)
pubnub_mutex_lock(pb_clone->monitor);
pb_clone->core.auth_token = pb->core.auth_token;
pb_clone->core.auth = pb->core.auth;
if (pb_clone->core.user_id_len != pb->core.user_id_len) {
if (NULL != pb_clone->core.user_id) free(pb_clone->core.user_id);
pb_clone->core.user_id_len = pb->core.user_id_len;
pb_clone->core.user_id = (char*)malloc((pb->core.user_id_len + 1) * sizeof(char));
}
strcpy(pb_clone->core.user_id, pb->core.user_id);
if (PUBNUB_ORIGIN_SETTABLE) {
pb_clone->origin = pb->origin;
Expand Down Expand Up @@ -443,9 +448,7 @@ int pubnub_set_heartbeat_period(pubnub_t* pb, size_t period_sec)
return -1;
}
pubnub_mutex_lock(m_watcher.mutw);
m_watcher.heartbeat_data[pb->thumperIndex].period_sec =
period_sec < PUBNUB_MIN_HEARTBEAT_PERIOD ? PUBNUB_MIN_HEARTBEAT_PERIOD
: period_sec;
m_watcher.heartbeat_data[pb->thumperIndex].period_sec = period_sec;
pubnub_mutex_unlock(pb->monitor);
pubnub_mutex_unlock(m_watcher.mutw);

Expand Down
8 changes: 4 additions & 4 deletions core/pbcc_subscribe_event_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ enum pubnub_res pbcc_subscribe_ee_unsubscribe_all(pbcc_subscribe_ee_t* ee)
pubnub_mutex_unlock(ee->mutw);

pubnub_leave(ee->pb,
0 == strlen(ch) ? NULL : ch,
0 == strlen(cg) ? NULL : cg);
NULL == ch || 0 == strlen(ch) ? NULL : ch,
NULL == cg || 0 == strlen(cg) ? NULL : cg);
}
}

Expand Down Expand Up @@ -859,8 +859,8 @@ enum pubnub_res pbcc_subscribe_ee_unsubscribe_(
sending_leave = true;

pubnub_leave(ee->pb,
0 == strlen(ch) ? NULL : ch,
0 == strlen(cg) ? NULL : cg);
NULL == ch || 0 == strlen(ch) ? NULL : ch,
NULL == cg || 0 == strlen(cg) ? NULL : cg);
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/pbcc_subscribe_event_engine_transitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pbcc_ee_transition_t* pbcc_handshaking_state_transition_alloc(
pbcc_ee_data_value(context->channel_groups);
const char* channels = pbcc_ee_data_value(context->channels);

if (NULL != context && 0 == strlen(channels) &&
0 == strlen(channel_groups)) {
if (NULL != context && (NULL == channels || 0 == strlen(channels)) &&
(NULL == channel_groups || 0 == strlen(channel_groups))) {
target_state_type = SUBSCRIBE_EE_STATE_UNSUBSCRIBED;
data = 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 "5.0.0"
#define PUBNUB_SDK_VERSION "5.0.1"


#endif /* !defined INC_PUBNUB_VERSION_INTERNAL */
2 changes: 1 addition & 1 deletion core/test/pubnub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
#define PUBNUB_USE_FETCH_HISTORY 1
#endif

#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12

#ifndef PUBNUB_RAND_INIT_VECTOR
#define PUBNUB_RAND_INIT_VECTOR 1
Expand Down
2 changes: 1 addition & 1 deletion freertos/pubnub_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct pubnub_pal {
/** The maximum number of URL parameters that can be saved in the Pubnub
context.
*/
#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12
#endif

#if !defined(PUBNUB_MIN_WAIT_CONNECT_TIMER)
Expand Down
2 changes: 1 addition & 1 deletion openssl/pubnub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
these things all by himself using pubnub_heartbeat() transaction */
#define PUBNUB_USE_AUTO_HEARTBEAT 1
#endif
#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12

#ifndef PUBNUB_RAND_INIT_VECTOR
#define PUBNUB_RAND_INIT_VECTOR 1
Expand Down
2 changes: 1 addition & 1 deletion posix/pubnub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
#define PUBNUB_USE_AUTO_HEARTBEAT 1
#endif

#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12

#ifndef PUBNUB_RAND_INIT_VECTOR
#define PUBNUB_RAND_INIT_VECTOR 1
Expand Down
2 changes: 1 addition & 1 deletion qt/pubnub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#define PUBNUB_USE_AUTO_HEARTBEAT 1
#endif

#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12

#ifndef PUBNUB_RAND_INIT_VECTOR
#define PUBNUB_RAND_INIT_VECTOR 1
Expand Down
4 changes: 1 addition & 3 deletions qt/pubnub_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ int pubnub_qt::set_heartbeat_period(size_t period_sec)
if (false == d_auto_heartbeat_enabled) {
return -1;
}
d_auto_heartbeat_period_sec =
period_sec < PUBNUB_MIN_HEARTBEAT_PERIOD ? PUBNUB_MIN_HEARTBEAT_PERIOD
: period_sec;
d_auto_heartbeat_period_sec = period_sec;
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion windows/pubnub_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
these things all by himself using pubnub_heartbeat() transaction */
#define PUBNUB_USE_AUTO_HEARTBEAT 1

#define PUBNUB_MAX_URL_PARAMS 10
#define PUBNUB_MAX_URL_PARAMS 12

#ifndef PUBNUB_RAND_INIT_VECTOR
#define PUBNUB_RAND_INIT_VECTOR 1
Expand Down
Loading