[pacman-dev] [PATCH 1/3] libalpm: correctly load signatures for package files

Dan McGee dpmcgee at gmail.com
Mon Apr 11 14:56:20 EDT 2011


On Sun, Apr 10, 2011 at 6:25 AM, Rémy Oudompheng
<remyoudompheng at 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 at 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\n", pkgfile);
>
>        /* If full is false, only read through the archive until we find our needed
> --
> 1.7.4.4


More information about the pacman-dev mailing list