GNU bug report logs - #11712
24.1.50; systime.h shouldn't cast time_t values to long

Previous Next

Package: emacs;

Reported by: Ulrich Mueller <ulm <at> gentoo.org>

Date: Thu, 14 Jun 2012 19:21:02 UTC

Severity: important

Tags: patch

Found in version 24.1.50

Fixed in version 24.2

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11712 in the body.
You can then email your comments to 11712 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Thu, 14 Jun 2012 19:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ulrich Mueller <ulm <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 14 Jun 2012 19:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ulrich Mueller <ulm <at> gentoo.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.1.50; systime.h shouldn't cast time_t values to long
Date: Thu, 14 Jun 2012 21:17:09 +0200
[Message part 1 (text/plain, inline)]
The EMACS_TIME_CMP macro defined in systime.h casts the seconds values
(which are of type time_t) to long. This is problematic on platforms
where time_t has 64 bits but long has only 32 bits, for example
GNU/Linux x64_64 systems with x32 ABI.

Attached patch should fix it.

[systime-time_t.diff (text/plain, inline)]
--- emacs-orig/src/ChangeLog
+++ emacs/src/ChangeLog
@@ -1,3 +1,7 @@
+2012-06-14  Ulrich Müller  <ulm <at> gentoo.org>
+
+	* systime.h (EMACS_TIME_CMP): Don't cast time_t values to long.
+
 2012-06-14  Paul Eggert  <eggert <at> cs.ucla.edu>
 
 	* .gdbinit (xgetint): Fix recently-introduced paren typo.
--- emacs-orig/src/systime.h
+++ emacs/src/systime.h
@@ -147,15 +147,12 @@
 #endif
 
 /* Compare times T1 and T2.  Value is 0 if T1 and T2 are the same.
-   Value is < 0 if T1 is less than T2.  Value is > 0 otherwise.  (Cast
-   to long is for those platforms where time_t is an unsigned
-   type, and where otherwise T1 will always be grater than T2.)  */
+   Value is < 0 if T1 is less than T2.  Value is > 0 otherwise.  */
 
 #define EMACS_TIME_CMP(T1, T2)				\
-  ((long)EMACS_SECS (T1) - (long)EMACS_SECS (T2)	\
-   + (EMACS_SECS (T1) == EMACS_SECS (T2)		\
-      ? EMACS_USECS (T1) - EMACS_USECS (T2)		\
-      : 0))
+  (EMACS_SECS (T1) == EMACS_SECS (T2)			\
+   ? EMACS_USECS (T1) - EMACS_USECS (T2)		\
+   : (EMACS_SECS (T1) < EMACS_SECS (T2) ? -1 : 1))
 
 /* Compare times T1 and T2 for equality, inequality etc.  */
 

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Thu, 21 Jun 2012 20:01:02 GMT) Full text and rfc822 format available.

Message #8 received at 11712 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Ulrich Mueller <ulm <at> gentoo.org>
Cc: 11712 <at> debbugs.gnu.org
Subject: Re: bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
Date: Thu, 21 Jun 2012 15:56:33 -0400
This seems important, but I'm not qualified to judge it, so I hope
someone who is looks at this patch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Mon, 25 Jun 2012 20:24:02 GMT) Full text and rfc822 format available.

Message #11 received at 11712 <at> debbugs.gnu.org (full text, mbox):

From: Ulrich Mueller <ulm <at> gentoo.org>
To: 11712 <at> debbugs.gnu.org
Subject: Re: bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
Date: Mon, 25 Jun 2012 22:19:36 +0200
Seems that it has been taken care of independently:
<http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/108687#src/systime.h>




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Mon, 25 Jun 2012 23:24:02 GMT) Full text and rfc822 format available.

Message #14 received at 11712 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Ulrich Mueller <ulm <at> gentoo.org>
Cc: 11712 <at> debbugs.gnu.org
Subject: Re: bug#11712: 24.1.50; systime.h shouldn't cast time_t values to long
Date: Mon, 25 Jun 2012 19:19:56 -0400
Ulrich Mueller wrote:

> Seems that it has been taken care of independently:
> <http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/108687#src/systime.h>

OK, good, if you say so! :)

I think it should somehow be fixed in the emacs-24 branch as well,
just in case.




bug Marked as fixed in versions 24.2. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 02 Aug 2012 18:38:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Tue, 14 Aug 2012 05:29:01 GMT) Full text and rfc822 format available.

Message #19 received at 11712 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Chong Yidong <cyd <at> gnu.org>
Cc: 11712 <at> debbugs.gnu.org
Subject: Re: Help with a bug
Date: Mon, 13 Aug 2012 22:19:32 -0700
On 08/13/2012 09:43 PM, Chong Yidong wrote:

> The patch proposed by Ulrich seems safer for 24.2.

Yes, I agree.  I reviewed the patch in
<http://bugs.gnu.org/11712#5>
and it looks good to me.  I didn't test it or anything
like that; I merely read it.

Please note that the attachment in
<http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;filename=systime-time_t.diff;att=1;bug=11712>
is problematic because it uses UTF-8 encoding but the HTTP
server doesn't say so in the HTTP header; please be careful if
you use that attachment, or otherwise Ulrich's last name might be
misspelled in the ChangeLog entry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11712; Package emacs. (Tue, 14 Aug 2012 07:08:01 GMT) Full text and rfc822 format available.

Message #22 received at 11712 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 11712 <at> debbugs.gnu.org
Subject: Re: bug#11712: Help with a bug
Date: Tue, 14 Aug 2012 14:58:40 +0800
Paul Eggert <eggert <at> cs.ucla.edu> writes:

> I reviewed the patch in <http://bugs.gnu.org/11712#5> and it looks
> good to me.  I didn't test it or anything like that; I merely read it.

Thanks.  Committed to the branch.




bug closed, send any further explanations to 11712 <at> debbugs.gnu.org and Ulrich Mueller <ulm <at> gentoo.org> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 14 Aug 2012 07:08:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 11 Sep 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.