From owner-cvs-all@FreeBSD.ORG Mon Aug 7 03:59:37 2006 Return-Path: X-Original-To: cvs-all@freebsd.org Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C9E4116A4E0; Mon, 7 Aug 2006 03:59:37 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2F29243D5A; Mon, 7 Aug 2006 03:59:37 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id C23DF61FDFA; Mon, 7 Aug 2006 13:59:35 +1000 (EST) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k773xUqx001143; Mon, 7 Aug 2006 13:59:33 +1000 Date: Mon, 7 Aug 2006 13:59:30 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= In-Reply-To: <8664h6ci86.fsf@xps.des.no> Message-ID: <20060807133921.V6590@delplex.bde.org> References: <200608042128.k74LShD7052071@repoman.freebsd.org> <8664h6ci86.fsf@xps.des.no> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-2050910349-1154923170=:6590" Cc: cvs-src@freebsd.org, Marcel Moolenaar , src-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/usr.sbin/kldxref kldxref.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2006 03:59:37 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-2050910349-1154923170=:6590 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Sun, 6 Aug 2006, Dag-Erling [iso-8859-1] Sm=F8rgrav wrote: > Marcel Moolenaar writes: >> Log: >> Fix (static) buffer overflow bug. The dest buffer is of size MAXPATHLE= N, >> so dest[MAXPATHLEN] falls outside the buffer. This bug corrupted >> arenas[0] defined in libc's malloc.c on PowerPC when kldxref is shared= , >> which triggered a delayed SIGSERV. > > MAXPATHLEN should be spelled PATH_MAX. Actually, MAXPATHLEN is better since it is honestly unportable. It works on all [Free]BSD systems, while PATH_MAX only works on POSIX systems that define it. The correct spelling of PATH_MAX is {PATH_MAX} or: #if defined(PATH_MAX) && defined(OPTIMIZE_FOR_COMPILE_TIME_CONST_PATH_MAX) =09char buf[PATH_MAX]; =09... #else =09long path_max; =09path_max =3D pathconf(pathname_of_interest, _PC_PATH_MAX); =09if (path_max =3D=3D -1) =09=09handle_error(); =09assert(path_max > 0 && path_max <=3D SIZE_MAX) =09buf =3D malloc((size_t)path_max); =09if (buf =3D=3D NULL) =09=09handle_allocation_failure(); =09... #endif The correct spelling is too hard to use for simple unportable utilities like kldxref. Bruce --0-2050910349-1154923170=:6590--