Blob Blame History Raw
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	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;
 
   if (negative && ns != 0)
     {