xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] When a VM's wallclock offset is negative enough, gmtime() can be called
@ 2010-05-25 14:50 Tim Deegan
  2010-05-25 15:02 ` Dan Magenheimer
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Deegan @ 2010-05-25 14:50 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 192 bytes --]

with an underflowed uint64, which it then tries to divide into years by
subtraction.  Handle the input as a 40-bit signed integer instead.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>



[-- Attachment #2: xen-unstable.hg.patch --]
[-- Type: text/x-patch, Size: 1294 bytes --]

# HG changeset patch
# User Tim Deegan <Tim.Deegan@citrix.com>
# Date 1274798631 -3600
# Node ID a723c31e10d17de54a5cee1024e01f600ba031cd
# Parent  7b11ebe91a678090fee7aee6c74e3dd09df27eb7
When a VM's wallclock offset is negative enough, gmtime() can be called
with an underflowed uint64, which it then tries to divide into years by
subtraction.  Handle the input as a 40-bit signed integer instead.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>

diff -r 7b11ebe91a67 -r a723c31e10d1 xen/common/time.c
--- a/xen/common/time.c	Tue May 25 15:43:46 2010 +0100
+++ b/xen/common/time.c	Tue May 25 15:43:51 2010 +0100
@@ -42,6 +42,18 @@
     int y;
     const unsigned short int *ip;
 
+    y = 1970;
+#ifdef __x86_64__
+    /* Allow the concept of time before 1970.  64-bit only; for 32-bit
+     * time after 2038 seems more important than time before 1970. */
+    while ( t & (1UL<<39) )
+    {
+        y -= 400;
+        t += ((unsigned long)(365 * 303 + 366 * 97)) * SECS_PER_DAY;
+    }
+    t &= (1UL << 40) - 1;
+#endif
+
     days = t / SECS_PER_DAY;
     rem = t % SECS_PER_DAY;
 
@@ -53,7 +65,6 @@
     tbuf.tm_wday = (4 + days) % 7;
     if ( tbuf.tm_wday < 0 )
         tbuf.tm_wday += 7;
-    y = 1970;
     while ( days >= (rem = __isleap(y) ? 366 : 365) )
     {
         ++y;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] When a VM's wallclock offset is negative enough,  gmtime() can be called
  2010-05-25 14:50 [PATCH] When a VM's wallclock offset is negative enough, gmtime() can be called Tim Deegan
@ 2010-05-25 15:02 ` Dan Magenheimer
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Magenheimer @ 2010-05-25 15:02 UTC (permalink / raw)
  To: Tim Deegan, xen-devel

+ /* Allow the concept of time before 1970.  64-bit only; for 32-bit

/me pictures Tim as a 1960's beatnik :-)

> -----Original Message-----
> From: Tim Deegan [mailto:Tim.Deegan@citrix.com]
> Sent: Tuesday, May 25, 2010 8:50 AM
> To: xen-devel@lists.xensource.com
> Subject: [Xen-devel] [PATCH] When a VM's wallclock offset is negative
> enough, gmtime() can be called
> 
> with an underflowed uint64, which it then tries to divide into years by
> subtraction.  Handle the input as a 40-bit signed integer instead.
> 
> Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-25 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 14:50 [PATCH] When a VM's wallclock offset is negative enough, gmtime() can be called Tim Deegan
2010-05-25 15:02 ` Dan Magenheimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).