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
=== 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;
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel