mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 10:38:05 +00:00
lib: fix access to stack value
Passing stack value to thread_add_* causes thread->ref to become an invalid pointer when the value goes out of scope Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
56afaa8bcb
commit
368d025eca
22
lib/thread.c
22
lib/thread.c
@ -613,6 +613,7 @@ thread_get (struct thread_master *m, u_char type,
|
|||||||
thread->arg = arg;
|
thread->arg = arg;
|
||||||
thread->index = -1;
|
thread->index = -1;
|
||||||
thread->yield = THREAD_YIELD_TIME_SLOT; /* default */
|
thread->yield = THREAD_YIELD_TIME_SLOT; /* default */
|
||||||
|
thread->ref = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So if the passed in funcname is not what we have
|
* So if the passed in funcname is not what we have
|
||||||
@ -829,12 +830,12 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
|
|||||||
thread_add_fd (m->write, thread);
|
thread_add_fd (m->write, thread);
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&thread->mtx);
|
pthread_mutex_unlock (&thread->mtx);
|
||||||
}
|
|
||||||
|
|
||||||
if (t_ptr)
|
if (t_ptr)
|
||||||
{
|
{
|
||||||
*t_ptr = thread;
|
*t_ptr = thread;
|
||||||
thread->ref = t_ptr;
|
thread->ref = t_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&m->mtx);
|
pthread_mutex_unlock (&m->mtx);
|
||||||
@ -869,14 +870,13 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
|
|||||||
monotime(&thread->u.sands);
|
monotime(&thread->u.sands);
|
||||||
timeradd(&thread->u.sands, time_relative, &thread->u.sands);
|
timeradd(&thread->u.sands, time_relative, &thread->u.sands);
|
||||||
pqueue_enqueue(thread, queue);
|
pqueue_enqueue(thread, queue);
|
||||||
|
if (t_ptr)
|
||||||
|
{
|
||||||
|
*t_ptr = thread;
|
||||||
|
thread->ref = t_ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&thread->mtx);
|
pthread_mutex_unlock (&thread->mtx);
|
||||||
|
|
||||||
if (t_ptr)
|
|
||||||
{
|
|
||||||
*t_ptr = thread;
|
|
||||||
thread->ref = t_ptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock (&m->mtx);
|
pthread_mutex_unlock (&m->mtx);
|
||||||
}
|
}
|
||||||
|
14
lib/vty.c
14
lib/vty.c
@ -2613,20 +2613,18 @@ static struct thread_master *vty_master;
|
|||||||
static void
|
static void
|
||||||
vty_event (enum event event, int sock, struct vty *vty)
|
vty_event (enum event event, int sock, struct vty *vty)
|
||||||
{
|
{
|
||||||
struct thread *vty_serv_thread;
|
|
||||||
|
|
||||||
switch (event)
|
switch (event)
|
||||||
{
|
{
|
||||||
case VTY_SERV:
|
case VTY_SERV:
|
||||||
vty_serv_thread = NULL;
|
vector_set_index (Vvty_serv_thread, sock, NULL);
|
||||||
thread_add_read(vty_master, vty_accept, vty, sock, &vty_serv_thread);
|
thread_add_read(vty_master, vty_accept, vty, sock,
|
||||||
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
|
(struct thread **) &Vvty_serv_thread->index[sock]);
|
||||||
break;
|
break;
|
||||||
#ifdef VTYSH
|
#ifdef VTYSH
|
||||||
case VTYSH_SERV:
|
case VTYSH_SERV:
|
||||||
vty_serv_thread = NULL;
|
vector_set_index (Vvty_serv_thread, sock, NULL);
|
||||||
thread_add_read(vty_master, vtysh_accept, vty, sock, &vty_serv_thread);
|
thread_add_read(vty_master, vtysh_accept, vty, sock,
|
||||||
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
|
(struct thread **) &Vvty_serv_thread->index[sock]);
|
||||||
break;
|
break;
|
||||||
case VTYSH_READ:
|
case VTYSH_READ:
|
||||||
vty->t_read = NULL;
|
vty->t_read = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user