Bug 785760

Summary: libtar: file descriptor leaks reported by cppcheck
Product: Red Hat Enterprise Linux 7 Reporter: Karel Volný <kvolny>
Component: libtarAssignee: Kamil Dudka <kdudka>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: medium    
Version: 7.0CC: emajorsi, jscotka, ovasik
Target Milestone: alphaKeywords: Patch
Target Release: 7.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libtar-1.2.11-29.el7 Doc Type: Bug Fix
Doc Text:
Previously, the error handling code in libtar did not properly release file descriptors before losing track of them. This led to unnecessary file descriptor leakage. An upstream patch has been applied on libtar source code to properly release file descriptors on error paths. Now, libtar no longer leaks file descriptors.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-18 08:22:19 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1191020    
Attachments:
Description Flags
proposed fix none

Description Karel Volný 2012-01-30 14:57:11 UTC
Description of problem:
Running cppcheck on libtar sources reports several errors - resource leaks.
As far as I can understand the source code, these are valid concerns, files are being opened, and in case of some errors, the functions exit without closing the files.

Version-Release number of selected component (if applicable):
libtar-1.2.11-17.el6

How reproducible:
always

Steps to Reproduce:
1. rpm -i libtar-1.2.11-17.el6.src.rpm
2. cppcheck /root/rpmbuild/BUILD/libtacat newr-1.2.11/ | grep error
  
Actual results:
[/root/rpmbuild/BUILD/libtar-1.2.11/lib/append.c:237]: (error) Resource leak: filefd
[/root/rpmbuild/BUILD/libtar-1.2.11/lib/extract.c:249]: (error) Resource leak: fdout
[/root/rpmbuild/BUILD/libtar-1.2.11/libtar/libtar.c:86]: (error) Resource leak: fd


Expected results:
(no output)

Additional info:

Comment 1 Kamil Dudka 2012-02-07 13:08:27 UTC
Created attachment 559936 [details]
proposed fix

Comment 3 Suzanne Logcher 2012-02-14 23:29:39 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 8 Kamil Dudka 2013-10-04 12:47:57 UTC
fixed in libtar-1.2.11-27.fc21

Comment 11 Kamil Dudka 2014-10-23 15:26:46 UTC
It is too late to fix the bug in RHEL-6.  I am moving it to RHEL-7...

Comment 13 Kamil Dudka 2015-04-21 18:51:04 UTC
up2date cppcheck does not detect the descriptor leaks above.  However, it detects a memory leak on OOM path, which I reported upstream:

https://lists.feep.net:8080/pipermail/libtar/2015-April/000412.html

... but I am not going to fix that one in RHEL.

Comment 14 Kamil Dudka 2015-04-22 15:07:56 UTC
reproducible with cppcheck-1.53

Comment 21 errata-xmlrpc 2015-05-18 08:22:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1014.html