From owner-p4-projects@FreeBSD.ORG Sat May 15 05:00:06 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0B14D1065674; Sat, 15 May 2010 05:00:06 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C228C106566C for ; Sat, 15 May 2010 05:00:05 +0000 (UTC) (envelope-from gcooper@FreeBSD.org) Received: from repoman.freebsd.org (unknown [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 85C448FC08 for ; Sat, 15 May 2010 05:00:05 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id o4F503rZ035215 for ; Sat, 15 May 2010 05:00:03 GMT (envelope-from gcooper@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id o4F503i3035213 for perforce@freebsd.org; Sat, 15 May 2010 05:00:03 GMT (envelope-from gcooper@FreeBSD.org) Date: Sat, 15 May 2010 05:00:03 GMT Message-Id: <201005150500.o4F503i3035213@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gcooper@FreeBSD.org using -f From: Garrett Cooper To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 178286 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2010 05:00:06 -0000 http://p4web.freebsd.org/@@178286?ac=10 Change 178286 by gcooper@starr-bastion on 2010/05/15 04:59:21 1. Fix the prototype mismatch for unpack_to_buffer function. 2. Nuke all of the user-specifiable data as I'm almost positive that the user specified buffer never be large enough to fit, and whether or not the user was specifying heap or stack based buffers would be problematic to determine. Affected files ... .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/file.c#10 edit .. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#5 edit Differences ... ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/file.c#10 (text+ko) ==== @@ -354,11 +354,11 @@ * returns NULL on failure. */ char* -unpack_to_buffer(char *buffer, const char *pkg, const char *file) +unpack_to_buffer(const char *pkg, const char *file) { FILE *fd = NULL; - char *buf = buffer; + char *buf = NULL; struct stat sb; if ((fd = unpack_to_fd(pkg, file)) != NULL) { @@ -370,22 +370,12 @@ * to malloc on the fly and let the user deal with it * later. */ - if (buf != NULL) - buf = malloc(sb.st_size); + buf = malloc(sb.st_size); if (buf != NULL) { - if (fread(buf, sb.st_size, 1, fd) != sb.st_size) { - - /* - * Don't try to free user specified - * memory. - */ - if (buffer == NULL) - free(buf); - + free(buf); } - } } ==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#5 (text+ko) ==== @@ -189,8 +189,7 @@ void copy_hierarchy(const char *, const char *, Boolean); int delete_hierarchy(const char *, Boolean, Boolean); int unpack(const char *, const char *); -char* unpack_to_buffer(struct archive *archive, const char *, - const char *); +char* unpack_to_buffer(const char *, const char *); FILE* unpack_to_fd(const char *, const char *); void format_cmd(char *, int, const char *, const char *, const char *);