From 444915e61f2e9533fb03f4fadb64d37a8e98787d Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 9 Jan 2017 05:44:19 +0000 Subject: [PATCH] MFC r310608: Avoid use after free. git-svn-id: svn://svn.freebsd.org/base/stable/10@311747 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- libexec/talkd/table.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c index 70b71b2c9..6b702e522 100644 --- a/libexec/talkd/table.c +++ b/libexec/talkd/table.c @@ -82,14 +82,15 @@ static TABLE_ENTRY *table = NIL; CTL_MSG * find_match(CTL_MSG *request) { - TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr, *next; time_t current_time; gettimeofday(&tp, NULL); current_time = tp.tv_sec; if (debug) print_request("find_match", request); - for (ptr = table; ptr != NIL; ptr = ptr->next) { + for (ptr = table; ptr != NIL; ptr = next) { + next = ptr->next; if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) @@ -115,7 +116,7 @@ find_match(CTL_MSG *request) CTL_MSG * find_request(CTL_MSG *request) { - TABLE_ENTRY *ptr; + TABLE_ENTRY *ptr, *next; time_t current_time; gettimeofday(&tp, NULL); @@ -126,7 +127,8 @@ find_request(CTL_MSG *request) */ if (debug) print_request("find_request", request); - for (ptr = table; ptr != NIL; ptr = ptr->next) { + for (ptr = table; ptr != NIL; ptr = next) { + next = ptr->next; if ((ptr->time - current_time) > MAX_LIFE) { /* the entry is too old */ if (debug) -- 2.42.0