- fix #432330 segfault on corrupted status file

This commit is contained in:
Tomas Smetana 2008-02-11 10:41:13 +00:00
parent 5b32d9402d
commit 4ff29482eb
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,52 @@
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);
- free(argv);
+ if(argv)
+ free(argv);
}
fclose(f);

View File

@ -1,7 +1,7 @@
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate
Version: 3.7.6
Release: 2.2%{?dist}
Release: 3%{?dist}
License: GPL+
Group: System Environment/Base
# The source for this package was pulled from cvs.
@ -13,6 +13,8 @@ Group: System Environment/Base
# make create-archive
Source: logrotate-%{version}.tar.gz
Patch1: logrotate-3.7.6-selinux.patch
Patch2: logrotate-3.7.6-segfault.patch
Requires: coreutils >= 5.92 libsepol libselinux popt
BuildRequires: libselinux-devel popt-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -31,6 +33,7 @@ log files on your system.
%prep
%setup -q
%patch1 -p1 -b .selinux
%patch2 -p1 -b .segfault
%build
make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
@ -60,6 +63,9 @@ rm -rf $RPM_BUILD_ROOT
%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
%changelog
* Mon Feb 11 2008 Tomas Smetana <tsmetana@redhat.com> 3.7.6-3
- fix #432330 segfault on corrupted status file
* Mon Jan 21 2008 Tomas Smetana <tsmetana@redhat.com> 3.7.6-2.2
- fix #429454 - logrotate fails due to invalid pointer