unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: 8664@debbugs.gnu.org
Subject: bug#8664: * keyboard.c (make_lispy_event): Fix problem in integer overflow.
Date: Thu, 12 May 2011 12:58:14 -0700	[thread overview]
Message-ID: <4DCC3BD6.3000200@cs.ucla.edu> (raw)

Here's a patch for a potential problem with integer overflow
on 64-bit hosts that I plan to install after some more testing.
The problem is a bit more severe if EMACS_INT is 64-bit on
a 32-bit host, and I found it by inspection.

* keyboard.c (make_lispy_event): Fix problem in integer overflow.
Don't assume that the difference between two unsigned long values
can fit into an integer.  At this point, we know button_down_time
<= event->timestamp, so the difference must be nonnegative, so
there's no need to cast the result if double-click-time is
nonnegative, as it should be; check that it's nonnegative, just in
case.  This bug is triggered when events are more than 2**31 ms
apart (about 25 days).
=== modified file 'src/keyboard.c'
--- src/keyboard.c	2011-04-28 19:35:20 +0000
+++ src/keyboard.c	2011-05-12 19:33:15 +0000
@@ -5556,9 +5556,9 @@
 		       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
 		       && button_down_time != 0
 		       && (EQ (Vdouble_click_time, Qt)
-			   || (INTEGERP (Vdouble_click_time)
-			       && ((int)(event->timestamp - button_down_time)
-				   < XINT (Vdouble_click_time)))));
+			   || (NATNUMP (Vdouble_click_time)
+			       && (event->timestamp - button_down_time
+				   < XFASTINT (Vdouble_click_time)))));
 	}

 	last_mouse_button = button;
@@ -5742,9 +5742,9 @@
 		       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
 		       && button_down_time != 0
 		       && (EQ (Vdouble_click_time, Qt)
-			   || (INTEGERP (Vdouble_click_time)
-			       && ((int)(event->timestamp - button_down_time)
-				   < XINT (Vdouble_click_time)))));
+			   || (NATNUMP (Vdouble_click_time)
+			       && (event->timestamp - button_down_time
+				   < XFASTINT (Vdouble_click_time)))));
 	  if (is_double)
 	    {
 	      double_click_count++;






             reply	other threads:[~2011-05-12 19:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 19:58 Paul Eggert [this message]
2011-05-12 20:26 ` bug#8664: Being more-systematic about user-interface timestamps Paul Eggert
2011-05-13  8:53   ` Eli Zaretskii
2011-05-14  9:10     ` Paul Eggert
2011-05-14  9:41       ` Eli Zaretskii
2011-05-14 19:09         ` Paul Eggert
2011-05-14 20:47           ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2011-05-16  5:07 bug#8675: lisp_string_width and strings wider than INT_MAX Paul Eggert
2011-05-16  5:30 ` Eli Zaretskii
2011-05-16  5:33   ` Paul Eggert
2011-05-16  7:57     ` Eli Zaretskii
2011-05-16 16:37       ` Paul Eggert
2011-05-16 16:48       ` Stefan Monnier
2011-05-17  9:52         ` Eli Zaretskii
2011-05-18  1:33 ` bug#8675: committed fix into trunk Paul Eggert
2011-05-18  2:26   ` Christoph Scholtes
2011-05-18  2:48     ` Paul Eggert
2011-05-18  3:19       ` Christoph Scholtes
2011-05-18 12:39       ` Andreas Schwab
2011-05-18 19:55         ` bug#8675: error: token "@" is not valid in preprocessor expressions Paul Eggert
     [not found]         ` <4DD42421.6090906@cs.ucla.edu>
2011-05-18 20:35           ` Andreas Schwab
     [not found]           ` <m262p7u4ph.fsf@igel.home>
2011-05-18 22:59             ` Paul Eggert
     [not found]             ` <4DD44F42.1050405@cs.ucla.edu>
2011-05-19  0:27               ` Bruno Haible
     [not found]               ` <201105190227.26215.bruno@clisp.org>
2011-05-19  1:47                 ` Christoph Scholtes
2011-05-19  7:39                   ` Paul Eggert
2011-05-18  6:54   ` bug#8664: committed fix into trunk Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DCC3BD6.3000200@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=8664@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).