From: Eli Zaretskii <eliz@gnu.org>
To: Jim Meyering <jim@meyering.net>
Cc: jakub@redhat.com, richard.guenther@gmail.com, 11288-done@debbugs.gnu.org
Subject: bug#11288: avoid buffer overrun in display code
Date: Fri, 20 Apr 2012 17:10:53 +0300 [thread overview]
Message-ID: <834nseijde.fsf@gnu.org> (raw)
In-Reply-To: <87397yljea.fsf@rho.meyering.net>
> From: Jim Meyering <jim@meyering.net>
> Date: Fri, 20 Apr 2012 13:42:05 +0200
> Cc: Jakub Jelinek <jakub@redhat.com>,
> Richard Guenther <richard.guenther@gmail.com>
>
> This bug leads to a seemingly unterminated loop in swap_glyph_pointers,
> when compiled with gcc-4.8.0 (from April 19 or newer).
> At first I thought it was a code-gen bug and reported it as
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53053. But then Richard
> Guenther guessed at the cause and Jakub Jelinek confirmed that the
> seemingly-infinite-loop was in fact just part of the undefined behavior
> we may now expect from buggy code.
>
> 2012-04-20 Jim Meyering <meyering@redhat.com>
>
> * dispextern.h (glyph_row.used): Increase size by 1, to avoid buffer
> overrun in swap_glyph_pointers, which reads and writes used[LAST_AREA].
> Reported as a gcc bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53053
> where Jakub Jelinek spotted the root cause.
>
> === modified file 'src/dispextern.h'
> --- src/dispextern.h 2012-03-26 05:43:05 +0000
> +++ src/dispextern.h 2012-04-20 11:14:29 +0000
> @@ -748,7 +748,7 @@
> struct glyph *glyphs[1 + LAST_AREA];
>
> /* Number of glyphs actually filled in areas. */
> - short used[LAST_AREA];
> + short used[1 + LAST_AREA];
>
> /* Window-relative x and y-position of the top-left corner of this
> row. If y < 0, this means that eabs (y) pixels of the row are
Thanks, I fixed it somewhat differently, see below.
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2012-04-20 06:39:29 +0000
+++ src/ChangeLog 2012-04-20 14:07:46 +0000
@@ -1,3 +1,8 @@
+2012-04-20 Eli Zaretskii <eliz@gnu.org>
+
+ * dispnew.c (swap_glyph_pointers, copy_row_except_pointers): Don't
+ overrun array limits of glyph row's used[] array. (Bug#11288)
+
2012-04-20 Chong Yidong <cyd@gnu.org>
* process.c (wait_reading_process_output): If EIO occurs on a pty,
=== modified file 'src/dispnew.c'
--- src/dispnew.c 2012-03-20 08:52:11 +0000
+++ src/dispnew.c 2012-04-20 14:04:13 +0000
@@ -1085,12 +1085,16 @@ swap_glyph_pointers (struct glyph_row *a
for (i = 0; i < LAST_AREA + 1; ++i)
{
struct glyph *temp = a->glyphs[i];
- short used_tem = a->used[i];
a->glyphs[i] = b->glyphs[i];
b->glyphs[i] = temp;
- a->used[i] = b->used[i];
- b->used[i] = used_tem;
+ if (i < LAST_AREA)
+ {
+ short used_tem = a->used[i];
+
+ a->used[i] = b->used[i];
+ b->used[i] = used_tem;
+ }
}
a->hash = b->hash;
b->hash = hash_tem;
@@ -1105,7 +1109,7 @@ static inline void
copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
{
struct glyph *pointers[1 + LAST_AREA];
- short used[1 + LAST_AREA];
+ short used[LAST_AREA];
unsigned hashval;
/* Save glyph pointers of TO. */
prev parent reply other threads:[~2012-04-20 14:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-20 11:42 bug#11288: avoid buffer overrun in display code Jim Meyering
2012-04-20 14:10 ` Eli Zaretskii [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=834nseijde.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=11288-done@debbugs.gnu.org \
--cc=jakub@redhat.com \
--cc=jim@meyering.net \
--cc=richard.guenther@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.