From owner-svn-src-all@FreeBSD.ORG Sat Dec 27 14:34:34 2008 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 376AE106568A; Sat, 27 Dec 2008 14:34:34 +0000 (UTC) (envelope-from flz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 241128FC19; Sat, 27 Dec 2008 14:34:34 +0000 (UTC) (envelope-from flz@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 mBREYXGK074051; Sat, 27 Dec 2008 14:34:33 GMT (envelope-from flz@svn.freebsd.org) Received: (from flz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBREYXNi074049; Sat, 27 Dec 2008 14:34:33 GMT (envelope-from flz@svn.freebsd.org) Message-Id: <200812271434.mBREYXNi074049@svn.freebsd.org> From: Florent Thoumie Date: Sat, 27 Dec 2008 14:34: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: r186518 - head/usr.sbin/pkg_install/lib 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: Sat, 27 Dec 2008 14:34:34 -0000 Author: flz Date: Sat Dec 27 14:34:33 2008 New Revision: 186518 URL: http://svn.freebsd.org/changeset/base/186518 Log: Fix memory leaks introduced in last commit. Bump version to 20081227. Reported by: gcooper Submitted by: Andrea Barberio MFC after: 1 month Modified: head/usr.sbin/pkg_install/lib/lib.h head/usr.sbin/pkg_install/lib/plist.c Modified: head/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- head/usr.sbin/pkg_install/lib/lib.h Sat Dec 27 14:32:39 2008 (r186517) +++ head/usr.sbin/pkg_install/lib/lib.h Sat Dec 27 14:34:33 2008 (r186518) @@ -105,7 +105,7 @@ * Version of the package tools - increase only when some * functionality used by bsd.port.mk is changed, added or removed */ -#define PKG_INSTALL_VERSION 20081225 +#define PKG_INSTALL_VERSION 20081227 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) Modified: head/usr.sbin/pkg_install/lib/plist.c ============================================================================== --- head/usr.sbin/pkg_install/lib/plist.c Sat Dec 27 14:32:39 2008 (r186517) +++ head/usr.sbin/pkg_install/lib/plist.c Sat Dec 27 14:34:33 2008 (r186518) @@ -544,9 +544,8 @@ delete_package(Boolean ign_err, Boolean int delete_hierarchy(const char *dir, Boolean ign_err, Boolean nukedirs) { - char *cp1, *cp2, *realdir; + char *cp1, *cp2, realdir[FILENAME_MAX]; - realdir = malloc(FILENAME_MAX); if (realdir == NULL) { warnx("Couldn't allocate enough memory\n"); return (ign_err ? SUCCESS : FAIL); @@ -555,7 +554,7 @@ delete_hierarchy(const char *dir, Boolea if (issymlink(dir) && readlink(dir, realdir, FILENAME_MAX-1) == -1) return (ign_err ? SUCCESS : FAIL); - strlcpy(realdir, dir, FILENAME_MAX); + strlcpy(realdir, dir, FILENAME_MAX-1); cp1 = cp2 = strdup(realdir); if (cp1 == NULL) { @@ -568,34 +567,29 @@ delete_hierarchy(const char *dir, Boolea warnx("%s '%s' doesn't exist", isdir(realdir) ? "directory" : "file", realdir); free(cp1); - free(realdir); return (ign_err ? SUCCESS : FAIL); } else if (nukedirs) { if (vsystem("%s -r%s %s", REMOVE_CMD, (ign_err ? "f" : ""), realdir)) { free(cp1); - free(realdir); return (ign_err ? SUCCESS : FAIL); } } else if (isdir(realdir)) { if (RMDIR(realdir)) { free(cp1); - free(realdir); return (ign_err ? SUCCESS : FAIL); } } else { if (REMOVE(realdir, ign_err)) { free(cp1); - free(realdir); return (ign_err ? SUCCESS : FAIL); } } if (!nukedirs) { free(cp1); - free(realdir); return (SUCCESS); } while (cp2) { @@ -603,18 +597,15 @@ delete_hierarchy(const char *dir, Boolea *cp2 = '\0'; if (!isemptydir(realdir)) { free(cp1); - free(realdir); return (SUCCESS); } if (RMDIR(realdir) && !ign_err) { if (!fexists(realdir)) { warnx("directory '%s' doesn't exist", realdir); free(cp1); - free(realdir); return (SUCCESS); } else { free(cp1); - free(realdir); return (FAIL); } } @@ -629,7 +620,6 @@ delete_hierarchy(const char *dir, Boolea } } free(cp1); - free(realdir); return (SUCCESS); }