From 9cc9e6b7bd7ac75cd963cd9e581cdceb511f122a Mon Sep 17 00:00:00 2001 From: Tomas Smetana Date: Wed, 23 Apr 2008 12:45:56 +0000 Subject: [PATCH] - improve patch for #432330 --- logrotate-3.7.6-fdclose.patch | 40 +++++++++++++++++++++++ logrotate-3.7.6-segfault.patch | 59 ++++++---------------------------- logrotate.spec | 5 ++- 3 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 logrotate-3.7.6-fdclose.patch diff --git a/logrotate-3.7.6-fdclose.patch b/logrotate-3.7.6-fdclose.patch new file mode 100644 index 0000000..f8b3cbb --- /dev/null +++ b/logrotate-3.7.6-fdclose.patch @@ -0,0 +1,40 @@ +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], diff --git a/logrotate-3.7.6-segfault.patch b/logrotate-3.7.6-segfault.patch index 6aa40ae..2c897b4 100644 --- a/logrotate-3.7.6-segfault.patch +++ b/logrotate-3.7.6-segfault.patch @@ -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') { diff --git a/logrotate.spec b/logrotate.spec index 0a7ca7c..7ecbfe1 100644 --- a/logrotate.spec +++ b/logrotate.spec @@ -1,7 +1,7 @@ Summary: Rotates, compresses, removes and mails system log files Name: logrotate Version: 3.7.6 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL+ Group: System Environment/Base # The source for this package was pulled from cvs. @@ -63,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT %attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status %changelog +* Wed Apr 23 2008 Tomas Smetana 3.7.6-4 +- improve patch for #432330 + * Mon Feb 11 2008 Tomas Smetana 3.7.6-3 - fix #432330 segfault on corrupted status file