From: "Grégoire Sutre" <gregoire.sutre@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: [patch] fix out-of-bounds error
Date: Mon, 19 Mar 2012 00:12:16 +0100 [thread overview]
Message-ID: <4F666BD0.6050103@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
I get the following warning on Debian GNU/Linux when compiling
with -O2. This is with GCC 4.6.3.
$ CFLAGS='-O2' ./configure && make
...
gdb/cstub.c: In function 'grub_gdb_trap':
gdb/cstub.c:83:21: error: array subscript is above array bounds
[-Werror=array-bounds]
cc1: all warnings being treated as errors
make[3]: *** [gdb/gdb_module-cstub.o] Error 1
make[3]: Leaving directory `/tmp/GRUB/trunk/grub-core'
Afaics, the out-of-bounds error is real, and the attached patch
fixes it.
Grégoire
[-- Attachment #2: gdb_cstub.diff --]
[-- Type: text/x-patch, Size: 851 bytes --]
=== modified file 'grub-core/gdb/cstub.c'
--- grub-core/gdb/cstub.c 2012-02-26 18:10:52 +0000
+++ grub-core/gdb/cstub.c 2012-03-18 13:46:51 +0000
@@ -57,27 +57,27 @@ grub_gdb_getpacket (void)
while (1)
{
/* Wait around for the start character, ignore all other
characters. */
while ((ch = grub_serial_port_fetch (grub_gdb_port)) != '$');
retry:
checksum = 0;
xmitcsum = -1;
count = 0;
/* Now read until a # or end of buffer is found. */
- while (count < GRUB_GDB_COMBUF_SIZE)
+ while (count < GRUB_GDB_COMBUF_SIZE - 1)
{
do
ch = grub_serial_port_fetch (grub_gdb_port);
while (ch < 0);
if (ch == '$')
goto retry;
if (ch == '#')
break;
checksum += ch;
buffer[count] = ch;
count = count + 1;
}
buffer[count] = 0;
reply other threads:[~2012-03-18 23:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4F666BD0.6050103@gmail.com \
--to=gregoire.sutre@gmail.com \
--cc=grub-devel@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.
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.