Date: Sat, 27 Dec 2008 14:34:33 +0000 (UTC) From: Florent Thoumie <flz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r186518 - head/usr.sbin/pkg_install/lib Message-ID: <200812271434.mBREYXNi074049@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <insomniac@slackware.it> 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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812271434.mBREYXNi074049>