Bug 8308

Summary: tar 1.13.16: fd leak because of opendir without closedir
Product: [Retired] Red Hat Linux Reporter: Jonathan Kamens <jik>
Component: tarAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-09 18:12:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jonathan Kamens 2000-01-09 16:25:58 UTC
There is a file descriptor leak in the 1.13.16 release of tar because of an
opendir in dump_file in create.c which is not followed by a corresponding
closedir.  Here's a fix:

--- create.c.orig	Sun Jan  9 11:27:23 2000
+++ create.c	Sun Jan  9 11:31:47 2000
@@ -1128,14 +1128,19 @@
 	    assign_string (&save_name, 0);
 	  if (atime_preserve_option)
 	    utime (p, &restore_times);
+          if (closedir (directory) != 0)
+            closedir_error (p);
 	  return;
 	}

       /* See if we are about to recurse into a directory, and avoid doing
 	 so if the user wants that we do not descend into directories.  */

-      if (no_recurse_option)
+      if (no_recurse_option) {
+        if (closedir (directory) != 0)
+          closedir_error (p);
 	return;
+      }

       /* See if we are crossing from one file system to another, and
 	 avoid doing so if the user only wants to dump one file system.  */
@@ -1146,6 +1151,8 @@
 	  if (verbose_option)
 	    WARN ((0, 0, _("%s is on a different filesystem; not dumped"),
 		   quote (p)));
+          if (closedir (directory) != 0)
+            closedir_error (p);
 	  return;
 	}

Comment 1 Bernhard Rosenkraenzer 2000-01-09 18:12:59 UTC
Thanks, fixed in 1.13.17-1