From 0b80e184d3c2448a7c9a47a25e45e599535372f51ddc53a9f3d729d022c0fd64 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 1 Nov 2017 13:01:50 +0000 Subject: [PATCH] - add 0001-Avoid-calling-close-on-undefined-fd-variable.patch OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=543 --- ...lling-close-on-undefined-fd-variable.patch | 39 +++++++++++++++++++ rpmlint.changes | 5 +++ rpmlint.spec | 1 + 3 files changed, 45 insertions(+) create mode 100644 0001-Avoid-calling-close-on-undefined-fd-variable.patch diff --git a/0001-Avoid-calling-close-on-undefined-fd-variable.patch b/0001-Avoid-calling-close-on-undefined-fd-variable.patch new file mode 100644 index 0000000..fe6b67b --- /dev/null +++ b/0001-Avoid-calling-close-on-undefined-fd-variable.patch @@ -0,0 +1,39 @@ +From 49611f900047d5397ebbbdb0ed5299580337ea34 Mon Sep 17 00:00:00 2001 +From: Dirk Mueller +Date: Wed, 1 Nov 2017 13:59:01 +0100 +Subject: [PATCH] Avoid calling close on undefined fd variable + +It can happen that open did through an OSError but then the +corresponding close UnknownVariableError wasn't caught. we +can fix that by putting both in the same try/exception block, +which also cleans up the code a bit. +--- + Pkg.py | 9 ++------- + 1 file changed, 2 insertions(+), 7 deletions(-) + +diff --git a/Pkg.py b/Pkg.py +index 47197c9..2622f9a 100644 +--- a/Pkg.py ++++ b/Pkg.py +@@ -719,16 +719,11 @@ class Pkg(AbstractPkg): + # use descriptor() method instead + try: + fd = os.open(pkgfile.path, os.O_RDONLY) +- except OSError: +- if not pkgfile.is_ghost: +- raise +- else: + pkgfile.magic = b2s(_magic.descriptor(fd)) +- # libmagic up to 5.18 already closes the descriptor +- try: + os.close(fd) + except OSError: +- pass ++ if not pkgfile.is_ghost: ++ raise + if pkgfile.magic is None: + pkgfile.magic = '' + elif Pkg._magic_from_compressed_re.search(pkgfile.magic): +-- +2.14.2 + diff --git a/rpmlint.changes b/rpmlint.changes index 32226f1..8139808 100644 --- a/rpmlint.changes +++ b/rpmlint.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Nov 1 13:01:32 UTC 2017 - dmueller@suse.com + +- add 0001-Avoid-calling-close-on-undefined-fd-variable.patch + ------------------------------------------------------------------- Tue Oct 24 12:54:47 UTC 2017 - jengelh@inai.de diff --git a/rpmlint.spec b/rpmlint.spec index 975557d..95e6b0a 100644 --- a/rpmlint.spec +++ b/rpmlint.spec @@ -87,6 +87,7 @@ Patch67: omit_BUILDROOT_from_pyo_files.patch Patch68: 0001-Avoid-false-positives-on-is_elf-check.patch Patch69: 0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch Patch70: rpmlint-all-pie.patch +Patch71: 0001-Avoid-calling-close-on-undefined-fd-variable.patch BuildRequires: obs-service-format_spec_file BuildRequires: python3-flake8 BuildRequires: python3-pytest