fix segfault with corrupted metadata in code_ns_fraction(#531441)

This commit is contained in:
Ondrej Vasik 2010-02-04 11:48:43 +00:00
parent 88bee905ac
commit b0701b539d
2 changed files with 28 additions and 11 deletions

View File

@ -1,12 +1,25 @@
diff -urNp tar-1.22-orig/src/misc.c tar-1.22/src/misc.c
--- tar-1.22-orig/src/misc.c 2007-06-27 15:30:32.000000000 +0200
+++ tar-1.22/src/misc.c 2009-12-08 13:41:46.000000000 +0100
@@ -228,7 +228,7 @@ code_ns_fraction (int ns, char *p)
*p = '\0';
else
{
- int i = 9;
+ int i = 10;
*p++ = '.';
+++ tar-1.22/src/misc.c 2010-02-04 12:05:00.000000000 +0100
@@ -255,7 +255,20 @@ code_timespec (struct timespec t, char s
time_t s = t.tv_sec;
int ns = t.tv_nsec;
char *np;
- bool negative = s < 0;
+ bool negative;
+
+ /* ignore any negative ns value */
+ if (ns < 0)
+ ns = 0;
+
+ /* ensure (ns < BILLION) to avoid SIGSEGV within code_ns_fraction () */
+ if (BILLION <= ns )
+ {
+ s += ns / BILLION;
+ ns %= BILLION;
+ }
+
+ negative = s < 0;
while (ns % 10 == 0)
if (negative && ns != 0)
{

View File

@ -5,7 +5,7 @@ Summary: A GNU file archiving program
Name: tar
Epoch: 2
Version: 1.22
Release: 14%{?dist}
Release: 15%{?dist}
License: GPLv3+
Group: Applications/Archiving
URL: http://www.gnu.org/software/tar/
@ -69,7 +69,7 @@ the rmt package.
%patch6 -p1 -b .shortread
%patch7 -p1 -b .headerblackmagic
%patch8 -p1 -b .xheaderleak
#%patch9 -p1 -b .nsfraction #causing stack smashing, do not apply
%patch9 -p1 -b .nsfraction
%patch10 -p1 -b .utimens
autoreconf
@ -132,6 +132,10 @@ fi
%{_infodir}/tar.info*
%changelog
* Thu Feb 04 2010 Ondrej Vasik <ovasik@redhat.com> 2:1.22-15
- fix segfault with corrupted metadata in code_ns_fraction
(#531441)
* Wed Feb 03 2010 Kamil Dudka <kdudka@redhat.com> 2:1.22-14
- allow also build with SELinux support