From owner-svn-src-stable@FreeBSD.ORG Fri Feb 1 07:38:27 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 54A693E9; Fri, 1 Feb 2013 07:38:27 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4776682; Fri, 1 Feb 2013 07:38:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r117cR79017415; Fri, 1 Feb 2013 07:38:27 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r117cR4b017414; Fri, 1 Feb 2013 07:38:27 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201302010738.r117cR4b017414@svn.freebsd.org> From: Xin LI Date: Fri, 1 Feb 2013 07:38:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r246198 - stable/8/lib/libc/gen X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2013 07:38:27 -0000 Author: delphij Date: Fri Feb 1 07:38:26 2013 New Revision: 246198 URL: http://svnweb.freebsd.org/changeset/base/246198 Log: MFC r244568: - Reduce buffer size from LINE_MAX to PATH_MAX, there is no point to store path longer than this. - Fix an unreached case of check against sizeof buf, which in turn leads to an off-by-one nul byte write on the stack. The original condition can never be satisfied because the passed boundary is the maximum value that can be returned, so code was harmless. Modified: stable/8/lib/libc/gen/check_utility_compat.c Directory Properties: stable/8/lib/libc/ (props changed) Modified: stable/8/lib/libc/gen/check_utility_compat.c ============================================================================== --- stable/8/lib/libc/gen/check_utility_compat.c Fri Feb 1 07:36:22 2013 (r246197) +++ stable/8/lib/libc/gen/check_utility_compat.c Fri Feb 1 07:38:26 2013 (r246198) @@ -35,32 +35,28 @@ __FBSDID("$FreeBSD$"); * are threaded, so I'm not concerned about cancellation points or other * niceties. */ +#include + #include #include #include #include -#ifndef LINE_MAX -#define LINE_MAX _POSIX2_LINE_MAX -#endif - #define _PATH_UTIL_COMPAT "/etc/compat-FreeBSD-4-util" #define _ENV_UTIL_COMPAT "_COMPAT_FreeBSD_4" int check_utility_compat(const char *utility) { - char buf[LINE_MAX]; + char buf[PATH_MAX]; char *p, *bp; int len; if ((p = getenv(_ENV_UTIL_COMPAT)) != NULL) { strlcpy(buf, p, sizeof buf); } else { - if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof buf)) < 0) + if ((len = readlink(_PATH_UTIL_COMPAT, buf, sizeof(buf) - 1)) < 0) return 0; - if (len > sizeof buf) - len = sizeof buf; buf[len] = '\0'; } if (buf[0] == '\0')