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

Fix UAF in dds_security_timed_dispatcher_add #1825

Merged
Merged
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
5 changes: 4 additions & 1 deletion src/security/core/src/dds_security_timed_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,17 @@
dds_security_time_event_handle_t dds_security_timed_dispatcher_add (struct dds_security_timed_dispatcher *d, dds_security_timed_cb_t cb, dds_time_t trigger_time, void *arg)
{
ddsrt_mutex_lock (&d->lock);
struct dds_security_timed_event * const ev = timed_event_new (d->next_timer, cb, trigger_time, arg);

Check failure

Code scanning / CodeQL

RULE-22-1: Memory allocated dynamically with Standard Library functions shall be explicitly released Error

The memory allocated here may not be freed at
this location
.
// cache the (unique) timer handle for the return because we can't guarantee that we return
// from this function before the newly created timer fires and is freed
const dds_security_time_event_handle_t timer_handle = ev->handle;
ddsrt_avl_insert (&timed_event_treedef, &d->events, ev);
ddsrt_fibheap_insert (&timed_cb_queue_fhdef, &d->timers, ev);
d->next_timer++;
if (d->evt != NULL)
(void) ddsi_resched_xevent_if_earlier (d->evt, calc_tsched (ev, dds_time ()));
ddsrt_mutex_unlock (&d->lock);
return ev->handle;
return timer_handle;
}

void dds_security_timed_dispatcher_remove (struct dds_security_timed_dispatcher *d, dds_security_time_event_handle_t timer)
Expand Down