From b0701b539d134a6030716b3e09d0c3fd71bcd42d Mon Sep 17 00:00:00 2001 From: Ondrej Vasik Date: Thu, 4 Feb 2010 11:48:43 +0000 Subject: [PATCH] fix segfault with corrupted metadata in code_ns_fraction(#531441) --- tar-1.22-nsfraction.patch | 31 ++++++++++++++++++++++--------- tar.spec | 8 ++++++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/tar-1.22-nsfraction.patch b/tar-1.22-nsfraction.patch index bd3b2df..2936a0b 100644 --- a/tar-1.22-nsfraction.patch +++ b/tar-1.22-nsfraction.patch @@ -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) + { diff --git a/tar.spec b/tar.spec index 22d216c..8736142 100644 --- a/tar.spec +++ b/tar.spec @@ -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 2:1.22-15 +- fix segfault with corrupted metadata in code_ns_fraction + (#531441) + * Wed Feb 03 2010 Kamil Dudka 2:1.22-14 - allow also build with SELinux support