diff options
author | delphij <delphij@FreeBSD.org> | 2017-01-09 05:44:19 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2017-01-09 05:44:19 +0000 |
commit | e7f94c53f45f460cb1e0f95457dada412fea78e0 (patch) | |
tree | 6738a52782af2b6bd5f2dc689c116274316c134d | |
parent | 69b215d0ea7c123ae8d78c1f2d9ae8d29f72e8e5 (diff) | |
download | FreeBSD-src-e7f94c53f45f460cb1e0f95457dada412fea78e0.zip FreeBSD-src-e7f94c53f45f460cb1e0f95457dada412fea78e0.tar.gz |
MFC r310608: Avoid use after free.
-rw-r--r-- | libexec/talkd/table.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libexec/talkd/table.c b/libexec/talkd/table.c index 70b71b2..6b702e5 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) |