* [patch] fix out-of-bounds error
@ 2012-03-18 23:12 Grégoire Sutre
0 siblings, 0 replies; only message in thread
From: Grégoire Sutre @ 2012-03-18 23:12 UTC (permalink / raw)
To: The development of GNU GRUB
[-- 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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-18 23:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-18 23:12 [patch] fix out-of-bounds error Grégoire Sutre
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.