From owner-svn-src-all@FreeBSD.ORG Sun Jan 5 21:44:05 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 53B92BC3; Sun, 5 Jan 2014 21:44:05 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3FE5C16CD; Sun, 5 Jan 2014 21:44:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s05Li5W1091676; Sun, 5 Jan 2014 21:44:05 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s05Li5oq091675; Sun, 5 Jan 2014 21:44:05 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201401052144.s05Li5oq091675@svn.freebsd.org> From: Jilles Tjoelker Date: Sun, 5 Jan 2014 21:44:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260336 - head/usr.bin/find X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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: Sun, 05 Jan 2014 21:44:05 -0000 Author: jilles Date: Sun Jan 5 21:44:04 2014 New Revision: 260336 URL: http://svnweb.freebsd.org/changeset/base/260336 Log: find: Fix -lname and -ilname. The code did not take into account that readlink() does not add a terminating '\0', and therefore did not work reliably. As before, symlinks of length PATH_MAX or more are not handled correctly. (These can only be created on other operating systems.) PR: bin/185393 Submitted by: Ben Reser (original version) MFC after: 1 week Modified: head/usr.bin/find/function.c Modified: head/usr.bin/find/function.c ============================================================================== --- head/usr.bin/find/function.c Sun Jan 5 21:35:07 2014 (r260335) +++ head/usr.bin/find/function.c Sun Jan 5 21:44:04 2014 (r260336) @@ -1122,11 +1122,14 @@ f_name(PLAN *plan, FTSENT *entry) { char fn[PATH_MAX]; const char *name; + ssize_t len; if (plan->flags & F_LINK) { - name = fn; - if (readlink(entry->fts_path, fn, sizeof(fn)) == -1) + len = readlink(entry->fts_path, fn, sizeof(fn) - 1); + if (len == -1) return 0; + fn[len] = '\0'; + name = fn; } else name = entry->fts_name; return !fnmatch(plan->c_data, name,