From owner-svn-src-head@freebsd.org Mon Dec 26 17:10:42 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C6073C92756; Mon, 26 Dec 2016 17:10:42 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95A6419DA; Mon, 26 Dec 2016 17:10:42 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBQHAfm1009808; Mon, 26 Dec 2016 17:10:41 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBQHAfse009807; Mon, 26 Dec 2016 17:10:41 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201612261710.uBQHAfse009807@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 26 Dec 2016 17:10:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310608 - head/libexec/talkd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2016 17:10:42 -0000 Author: delphij Date: Mon Dec 26 17:10:41 2016 New Revision: 310608 URL: https://svnweb.freebsd.org/changeset/base/310608 Log: Avoid use after free. Reported by: Clang static code analyzer MFC after: 2 weeks Modified: head/libexec/talkd/table.c Modified: head/libexec/talkd/table.c ============================================================================== --- head/libexec/talkd/table.c Mon Dec 26 16:45:00 2016 (r310607) +++ head/libexec/talkd/table.c Mon Dec 26 17:10:41 2016 (r310608) @@ -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)