[elbe-devel] [PATCH v3 3/4] Avoid segfault on reading package's md5 attribute

Bastian Germann bage at linutronix.de
Fri Aug 9 14:31:53 CEST 2019


> From: Olivier Dion <dion at linutronix.de>
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>  elbepack/aptpkgutils.py | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
> index 9c8b37ce..78b1b37b 100644
> --- a/elbepack/aptpkgutils.py
> +++ b/elbepack/aptpkgutils.py
> @@ -21,6 +21,13 @@ statestring = {
>      NOTINSTALLED: "NOT INSTALLED"
>  }
>  
> +def apt_pkg_md5(pkg):
> +    hashes = pkg.installed._records.hashes
> +    for i in xrange(len(hashes)):
> +        h = str(hashes[i])
> +        if h.startswith("MD5"):
> +            return h.split(':')[1]
> +    return None
>  
>  def getdeps(pkg):
>      for dd in pkg.dependencies:
> @@ -110,8 +117,9 @@ class APTPackage(PackageBase):
>  
>          iver = pkg.installed and pkg.installed.version
>          cver = pkg.candidate and pkg.candidate.version
> -        imd5 = pkg.installed and pkg.installed.md5
> -        cmd5 = pkg.candidate and pkg.candidate.md5
> +        imd5 = pkg.installed and apt_pkg_md5(pkg.installed)
> +        cmd5 = pkg.candidate and apt_pkg_md5(pkg.candidate)
> +
>          self.state = pkgstate(pkg)
>          self.is_auto_installed = pkg.is_auto_installed
>          origin = pkgorigin(pkg)
> 



More information about the elbe-devel mailing list