Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   libalpm: correctly load signatures for package files (http://www.linux-archive.org/archlinux-pacman-development/512879-libalpm-correctly-load-signatures-package-files.html)

Dan McGee 04-11-2011 06:56 PM

libalpm: correctly load signatures for package files
 
On Sun, Apr 10, 2011 at 6:25 AM, Rémy Oudompheng
<remyoudompheng@gmail.com> wrote:
> A duplicate _alpm_pkg_new() call made libalpm load the signature
> in a separate pmpkg_t that was leaked forever afterwards.
>
> Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
> ---
> This patch make the signatures for local files load
> correctly.

And now leaks an empty pmpkg_t object if the file could not be stat-ed
and we return early, no?

I think all we need to do is remove the now erroneous second call to
pkg_new; given this was a 2008 patch retrofitted to 2011 code, there
is no surprise Allan or I messed up slightly on the rebase.

> On branch 'master'
>
> *lib/libalpm/be_package.c | * 18 +++++-------------
> *1 files changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
> index a693247..d87d539 100644
> --- a/lib/libalpm/be_package.c
> +++ b/lib/libalpm/be_package.c
> @@ -251,15 +251,16 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
> * * * * * * * *RET_ERR(PM_ERR_WRONG_ARGS, NULL);
> * * * *}
>
> + * * * newpkg = _alpm_pkg_new();
> + * * * if(newpkg == NULL) {
> + * * * * * * * RET_ERR(PM_ERR_MEMORY, NULL);
> + * * * }
> +
> * * * */* attempt to stat the package file, ensure it exists */
> * * * *if(stat(pkgfile, &st) == 0) {
> * * * * * * * *char *pgpfile;
> * * * * * * * *int sig_ret;
>
> - * * * * * * * newpkg = _alpm_pkg_new();
> - * * * * * * * if(newpkg == NULL) {
> - * * * * * * * * * * * RET_ERR(PM_ERR_MEMORY, NULL);
> - * * * * * * * }
> * * * * * * * *newpkg->filename = strdup(pkgfile);
> * * * * * * * *newpkg->size = st.st_size;
>
> @@ -289,15 +290,6 @@ static pmpkg_t *pkg_load(const char *pkgfile, int full)
> * * * * * * * *RET_ERR(PM_ERR_PKG_OPEN, NULL);
> * * * *}
>
> - * * * newpkg = _alpm_pkg_new();
> - * * * if(newpkg == NULL) {
> - * * * * * * * archive_read_finish(archive);
> - * * * * * * * RET_ERR(PM_ERR_MEMORY, NULL);
> - * * * }
> -
> - * * * newpkg->filename = strdup(pkgfile);
> - * * * newpkg->size = st.st_size;
> -
> * * * *_alpm_log(PM_LOG_DEBUG, "starting package load for %s
", pkgfile);
>
> * * * */* If full is false, only read through the archive until we find our needed
> --
> 1.7.4.4


All times are GMT. The time now is 02:50 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.