unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jan Djärv" <jan.h.d@swipnet.se>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 9196@debbugs.gnu.org
Subject: bug#9196: integer and memory overflow issues (e.g., cut-and-paste crashes Emacs)
Date: Fri, 29 Jul 2011 12:01:15 +0200	[thread overview]
Message-ID: <4E3284EB.1010308@swipnet.se> (raw)
In-Reply-To: <4E3256E9.3020208@cs.ucla.edu>

Hello.

Since strlen is defined to return size_t and you store the result in a 
ptrdiff_t, does not that mean you have introduced a possible signed/unsigned 
conversion error?

  In gtkutil.c:

+      ptrdiff_t lim = min (TYPE_MAXIMUM (Window),
+			   min (PTRDIFF_MAX, SIZE_MAX) / sizeof (GtkWidget *));

Isn't this a compile time constant?  Should it not be a #define or something?
IMHO, the check in gtkutil.c will only call memory_full when there is 2^31 
(about 2 billion) scroll bars in Emacs.  Isn't it overengineering to check for 
that case?


In xgselect.c:

+	int gfds_size_max =
+	  min (INT_MAX, min (PTRDIFF_MAX, SIZE_MAX) / sizeof *gfds);

Here a compile time constant is recalculated inside a loop.
The xgselect.c is also overengineering IMHO.  The number checked represents 
the number of file descriptor sources Glib is checking.  I can understand 
checking sizes for strings that come from external sources, but only code adds 
file descriptor sources.  If some bug causes the addition of 2 billion 
sources, a crash would be fine by me.  Actually better than memory_full, 
because the core is much more useful.

I haven't looked at the other files.  I hope to find time to look at xselect.c 
at least.

	Jan D.







  reply	other threads:[~2011-07-29 10:01 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 [this message]
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
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=4E3284EB.1010308@swipnet.se \
    --to=jan.h.d@swipnet.se \
    --cc=9196@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).