From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 1 20:10:01 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.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 CA852BFA for ; Wed, 1 Jan 2014 20:10:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (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 B7C39117B for ; Wed, 1 Jan 2014 20:10:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id s01KA12E004046 for ; Wed, 1 Jan 2014 20:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id s01KA1GA004045; Wed, 1 Jan 2014 20:10:01 GMT (envelope-from gnats) Date: Wed, 1 Jan 2014 20:10:01 GMT Message-Id: <201401012010.s01KA1GA004045@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Ben Reser Subject: Re: bin/185393: find -lname buffer read overflow bug X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Ben Reser List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jan 2014 20:10:01 -0000 The following reply was made to PR bin/185393; it has been noted by GNATS. From: Ben Reser To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/185393: find -lname buffer read overflow bug Date: Wed, 01 Jan 2014 12:03:04 -0800 This is a multi-part message in MIME format. --------------080101030108030107080503 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Correction on the patch. Forgot to subtract one byte from the buffer to allow for the NULL character to be set. Updated patch attached. --------------080101030108030107080503 Content-Type: text/plain; charset=UTF-8; name="fbsd-find-lname.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fbsd-find-lname.patch.txt" Index: usr.bin/find/function.c =================================================================== --- usr.bin/find/function.c (revision 260159) +++ usr.bin/find/function.c (working copy) @@ -1124,9 +1124,11 @@ f_name(PLAN *plan, FTSENT *entry) const char *name; if (plan->flags & F_LINK) { + int len = readlink(entry->fts_path, fn, sizeof(fn) - 1); + if (len == -1) + return 0; + fn[len] = '\0'; name = fn; - if (readlink(entry->fts_path, fn, sizeof(fn)) == -1) - return 0; } else name = entry->fts_name; return !fnmatch(plan->c_data, name, --------------080101030108030107080503--