From owner-svn-src-all@FreeBSD.ORG Thu May 14 23:09:33 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B6CA0106568B; Thu, 14 May 2009 23:09:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 89BAB8FC21; Thu, 14 May 2009 23:09:33 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4EN9XEu005318; Thu, 14 May 2009 23:09:33 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4EN9XdU005317; Thu, 14 May 2009 23:09:33 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <200905142309.n4EN9XdU005317@svn.freebsd.org> From: Xin LI Date: Thu, 14 May 2009 23:09:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192129 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2009 23:09:37 -0000 Author: delphij Date: Thu May 14 23:09:33 2009 New Revision: 192129 URL: http://svn.freebsd.org/changeset/base/192129 Log: As the comment says, close() frees the variable, record. So we obtain the length by evaluating the value from the copy, cbuf instead. This fixes a crash caused by previous commit (use-after-free) Submitted by: Dimitry Andric Pointy hat to: delphij Modified: head/lib/libc/gen/getcap.c Modified: head/lib/libc/gen/getcap.c ============================================================================== --- head/lib/libc/gen/getcap.c Thu May 14 22:36:56 2009 (r192128) +++ head/lib/libc/gen/getcap.c Thu May 14 23:09:33 2009 (r192129) @@ -260,7 +260,7 @@ getent(char **cap, u_int *len, char **db errno = ENOMEM; return (-2); } - *len = strlen(record); + *len = strlen(cbuf); *cap = cbuf; return (retval); } else {