unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: 9196@debbugs.gnu.org
Subject: bug#9196: integer and memory overflow issues (e.g., cut-and-paste crashes Emacs)
Date: Sat, 30 Jul 2011 12:16:34 -0700	[thread overview]
Message-ID: <4E345892.8010200@cs.ucla.edu> (raw)
In-Reply-To: <4E339C30.9090708@swipnet.se>

I take your point that the checks add clutter, so I'll
revise the patch to address that problem, by adding a
couple of memory allocators that do the proper overflow
checking internally, so that callers don't need to
test for integer overflow.

This will take a bit of time to prepare and test, so
please bear with me, but to give you a feel here's a draft
of the revised patch to xgselect.c.  This simplifies
xgselect.c compared to what's in the trunk now.

--- src/xgselect.c	2011-07-01 09:18:46 +0000
+++ src/xgselect.c	2011-07-30 18:19:51 +0000
@@ -54,10 +54,8 @@
   do {
     if (n_gfds > gfds_size)
       {
-        while (n_gfds > gfds_size)
-          gfds_size *= 2;
         xfree (gfds);
-        gfds = xmalloc (sizeof (*gfds) * gfds_size);
+        gfds = xpmalloc (&gfds_size, n_gfds - gfds_size, INT_MAX, sizeof *gfds);
       }
 
     n_gfds = g_main_context_query (context,



On 07/29/11 22:52, Jan Djärv wrote:
> the checks that check for more than 2 billion command line arguments

Those checks are necessary for GNU/Hurd, which places
no limit on command line arguments, which means argc + 2
can overflow.  That being said, the revised patch will address
the clutter problem for the command-line issue as well, and
the resulting emacs.c will be simpler than what's in the
trunk now.





  reply	other threads:[~2011-07-30 19:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29  6:44 bug#9196: integer and memory overflow issues (e.g., cut-and-paste crashes Emacs) Paul Eggert
2011-07-29 10:01 ` Jan Djärv
2011-07-29 16:21   ` Paul Eggert
2011-07-29 16:49     ` Jan Djärv
2011-07-29 21:03       ` Paul Eggert
2011-07-30  5:52         ` Jan Djärv
2011-07-30 19:16           ` Paul Eggert [this message]
2011-07-31  8:57             ` Jan Djärv
2011-08-05  2:33               ` Paul Eggert
2011-08-05  9:26                 ` Jan Djärv
2011-08-06  1:24                   ` Paul Eggert
2011-08-08 18:01                     ` Jan Djärv
     [not found] ` <handler.9196.B.131192196724343.ack@debbugs.gnu.org>
2011-08-26 16:38   ` Paul Eggert

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=4E345892.8010200@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=9196@debbugs.gnu.org \
    --cc=jan.h.d@swipnet.se \
    /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).