diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-10-07 15:53:10 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-10-07 16:01:03 +0300 |
| commit | 7640e3c60b33e13376185a0e0c85f3f6c272d0a9 (patch) | |
| tree | 91dddddd3fe42fc4ce3e93d452b11504cf829083 /lib/northbound_sysrepo.c | |
| parent | b7a88ee2910a1c76ccbae38a9e7226d6c93fff37 (diff) | |
*: don't pass pointers to a local variables to thread_add_*
We should never pass pointers to local variables to thread_add_* family.
When an event is executed, the library writes into this pointer, which
means it writes into some random memory on a stack.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/northbound_sysrepo.c')
| -rw-r--r-- | lib/northbound_sysrepo.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 7c463dd61f..86a159e507 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -528,19 +528,18 @@ static int frr_sr_notification_send(const char *xpath, struct list *arguments) static int frr_sr_read_cb(struct thread *thread) { - sr_subscription_ctx_t *sr_subscription = THREAD_ARG(thread); + struct yang_module *module = THREAD_ARG(thread); int fd = THREAD_FD(thread); int ret; - ret = sr_process_events(sr_subscription, session, NULL); + ret = sr_process_events(module->sr_subscription, session, NULL); if (ret != SR_ERR_OK) { flog_err(EC_LIB_LIBSYSREPO, "%s: sr_fd_event_process(): %s", __func__, sr_strerror(ret)); return -1; } - thread = NULL; - thread_add_read(master, frr_sr_read_cb, sr_subscription, fd, &thread); + thread_add_read(master, frr_sr_read_cb, module, fd, &module->sr_thread); return 0; } @@ -703,7 +702,7 @@ static int frr_sr_init(void) sr_strerror(ret)); goto cleanup; } - thread_add_read(master, frr_sr_read_cb, module->sr_subscription, + thread_add_read(master, frr_sr_read_cb, module, event_pipe, &module->sr_thread); } |
