- improve patch for #432330

This commit is contained in:
Tomas Smetana 2008-04-23 12:45:56 +00:00
parent 4ff29482eb
commit 9cc9e6b7bd
3 changed files with 53 additions and 51 deletions

View File

@ -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],

View File

@ -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') {

View File

@ -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 <tsmetana@redhat.com> 3.7.6-4
- improve patch for #432330
* Mon Feb 11 2008 Tomas Smetana <tsmetana@redhat.com> 3.7.6-3
- fix #432330 segfault on corrupted status file