Author: delphij
Date: Mon Jan  9 05:44:19 2017
New Revision: 311747
URL: https://svnweb.freebsd.org/changeset/base/311747

Log:
  MFC r310608: Avoid use after free.

Modified:
  stable/10/libexec/talkd/table.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/libexec/talkd/table.c
==============================================================================
--- stable/10/libexec/talkd/table.c     Mon Jan  9 05:41:47 2017        
(r311746)
+++ stable/10/libexec/talkd/table.c     Mon Jan  9 05:44:19 2017        
(r311747)
@@ -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)
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to