rpms/logrotate/F-9 logrotate-3.7.6-fdclose.patch, NONE, 1.1 logrotate-3.7.6-segfault.patch, 1.1, 1.2 logrotate.spec, 1.71, 1.72

Tomas Smetana (tsmetana) fedora-extras-commits at redhat.com
Mon Jun 9 06:30:42 UTC 2008


Author: tsmetana

Update of /cvs/pkgs/rpms/logrotate/F-9
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32119

Modified Files:
	logrotate-3.7.6-segfault.patch logrotate.spec 
Added Files:
	logrotate-3.7.6-fdclose.patch 
Log Message:
* Mon Jun 09 2008 Tomas Smetana <tsmetana at redhat.com> 3.7.6-5
- don't forget to close the files so we don't leak the file
  descriptors (related #437748)


logrotate-3.7.6-fdclose.patch:

--- NEW FILE logrotate-3.7.6-fdclose.patch ---
diff -up logrotate-3.7.6/logrotate.c.fdclose logrotate-3.7.6/logrotate.c
--- logrotate-3.7.6/logrotate.c.fdclose	2008-04-21 11:49:57.000000000 +0200
+++ logrotate-3.7.6/logrotate.c	2008-04-21 11:53:08.000000000 +0200
@@ -935,6 +935,9 @@ int rotateSingleLog(logInfo * log, int l
 						if (oldContext != NULL) {
 							freecon(oldContext);
 						}
+						if (close(fdcurr) < 0)
+							message(MESS_ERROR, "error closing file %s",
+									log->files[logNum]);
 						return 1;
 					}
 				}
@@ -946,6 +949,9 @@ int rotateSingleLog(logInfo * log, int l
 						if (oldContext != NULL) {
 							freecon(oldContext);
 						}
+						if (close(fdcurr) < 0)
+							message(MESS_ERROR, "error closing file %s",
+									log->files[logNum]);
 						return 1;
 					}
 				}
@@ -959,10 +965,16 @@ int rotateSingleLog(logInfo * log, int l
 					message(MESS_ERROR, "getting file context %s: %s\n",
 						log->files[logNum], strerror(errno));
 					if (selinux_enforce) {
+						if (close(fdcurr) < 0)
+							message(MESS_ERROR, "error closing file %s",
+									log->files[logNum]);
 						return 1;
 					}
 				}
 			}
+			if (close(fdcurr) < 0)
+				message(MESS_ERROR, "error closing file %s",
+						log->files[logNum]);
 		}
 #endif
 		message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],

logrotate-3.7.6-segfault.patch:

Index: logrotate-3.7.6-segfault.patch
===================================================================
RCS file: /cvs/pkgs/rpms/logrotate/F-9/logrotate-3.7.6-segfault.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- logrotate-3.7.6-segfault.patch	11 Feb 2008 10:41:13 -0000	1.1
+++ logrotate-3.7.6-segfault.patch	9 Jun 2008 06:30:00 -0000	1.2
@@ -1,52 +1,11 @@
 diff -up logrotate-3.7.6/logrotate.c.segfault logrotate-3.7.6/logrotate.c
---- logrotate-3.7.6/logrotate.c.segfault	2008-02-11 11:33:52.000000000 +0100
-+++ logrotate-3.7.6/logrotate.c	2008-02-11 11:34:59.000000000 +0100
-@@ -1325,7 +1325,7 @@ static int readState(char *stateFilename
- {
-     FILE *f;
-     char buf[1024];
--    const char **argv;
-+    const char **argv = NULL;
-     int argc;
-     int year, month, day;
-     int i;
-@@ -1409,7 +1409,8 @@ static int readState(char *stateFilename
- 	    message(MESS_ERROR,
- 		    "bad year %d for file %s in state file %s\n", year,
- 		    argv[0], stateFilename);
--	    free(argv);
-+	    if(argv)
-+			free(argv);
- 	    fclose(f);
- 	    return 1;
- 	}
-@@ -1418,7 +1419,8 @@ static int readState(char *stateFilename
- 	    message(MESS_ERROR,
- 		    "bad month %d for file %s in state file %s\n", month,
- 		    argv[0], stateFilename);
--	    free(argv);
-+	    if(argv)
-+			free(argv);
- 	    fclose(f);
- 	    return 1;
- 	}
-@@ -1428,7 +1430,8 @@ static int readState(char *stateFilename
- 	    message(MESS_ERROR,
- 		    "bad day %d for file %s in state file %s\n", day,
- 		    argv[0], stateFilename);
--	    free(argv);
-+	    if(argv)
-+			free(argv);
- 	    fclose(f);
- 	    return 1;
- 	}
-@@ -1445,7 +1448,8 @@ static int readState(char *stateFilename
- 	lr_time = mktime(&st->lastRotated);
- 	st->lastRotated = *localtime(&lr_time);
+--- logrotate-3.7.6/logrotate.c.segfault	2008-04-23 14:40:51.000000000 +0200
++++ logrotate-3.7.6/logrotate.c	2008-04-23 14:41:14.000000000 +0200
+@@ -1380,6 +1380,7 @@ static int readState(char *stateFilename
+     line++;
  
--	free(argv);
-+	if(argv)
-+		free(argv);
-     }
- 
-     fclose(f);
+     while (fgets(buf, sizeof(buf) - 1, f)) {
++	argv = NULL;
+ 	line++;
+ 	i = strlen(buf);
+ 	if (buf[i - 1] != '\n') {


Index: logrotate.spec
===================================================================
RCS file: /cvs/pkgs/rpms/logrotate/F-9/logrotate.spec,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- logrotate.spec	11 Feb 2008 10:41:13 -0000	1.71
+++ logrotate.spec	9 Jun 2008 06:30:00 -0000	1.72
@@ -1,7 +1,7 @@
 Summary: Rotates, compresses, removes and mails system log files
 Name: logrotate
 Version: 3.7.6
-Release: 3%{?dist}
+Release: 5%{?dist}
 License: GPL+
 Group: System Environment/Base
 # The source for this package was pulled from cvs.
@@ -14,6 +14,7 @@
 Source: logrotate-%{version}.tar.gz
 Patch1: logrotate-3.7.6-selinux.patch
 Patch2: logrotate-3.7.6-segfault.patch
+Patch3: logrotate-3.7.6-fdclose.patch
 
 Requires: coreutils >= 5.92 libsepol libselinux popt
 BuildRequires: libselinux-devel popt-devel
@@ -34,6 +35,7 @@
 %setup -q
 %patch1 -p1 -b .selinux
 %patch2 -p1 -b .segfault
+%patch3 -p1 -b .fdclose
 
 %build
 make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
@@ -63,6 +65,13 @@
 %attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
 
 %changelog
+* Mon Jun 09 2008 Tomas Smetana <tsmetana at redhat.com> 3.7.6-5
+- don't forget to close the files so we don't leak the file
+  descriptors (related #437748)
+
+* Wed Apr 23 2008 Tomas Smetana <tsmetana at redhat.com> 3.7.6-4
+- improve patch for #432330
+
 * Mon Feb 11 2008 Tomas Smetana <tsmetana at redhat.com> 3.7.6-3
 - fix #432330 segfault on corrupted status file
 




More information about the fedora-extras-commits mailing list