From: Daniel Jacobowitz Date: Thu, 12 Nov 2009 21:01:00 +0000 (+0000) Subject: * remote-fileio.c (remote_fileio_func_read): Limit console X-Git-Tag: cgen-snapshot-20091201~188 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b86ab4ff1548b4524bb90e3348ae416c586e8380;p=platform%2Fupstream%2Fbinutils.git * remote-fileio.c (remote_fileio_func_read): Limit console reads to 16K. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 424383d..275955c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,9 @@ 2009-11-12 Daniel Jacobowitz + + * remote-fileio.c (remote_fileio_func_read): Limit console + reads to 16K. + +2009-11-12 Daniel Jacobowitz Paul Brook * c-typeprint.c (c_type_print_base): Skip artificial fields. diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c index 1683e99..31ee244 100644 --- a/gdb/remote-fileio.c +++ b/gdb/remote-fileio.c @@ -741,7 +741,7 @@ remote_fileio_func_read (char *buf) static char *remaining_buf = NULL; static int remaining_length = 0; - buffer = (gdb_byte *) xmalloc (32768); + buffer = (gdb_byte *) xmalloc (16384); if (remaining_buf) { remote_fio_no_longjmp = 1; @@ -763,7 +763,18 @@ remote_fileio_func_read (char *buf) } else { - ret = ui_file_read (gdb_stdtargin, (char *) buffer, 32767); + /* Windows (at least XP and Server 2003) has difficulty + with large reads from consoles. If a handle is + backed by a real console device, overly large reads + from the handle will fail and set errno == ENOMEM. + On a Windows Server 2003 system where I tested, + reading 26608 bytes from the console was OK, but + anything above 26609 bytes would fail. The limit has + been observed to vary on different systems. So, we + limit this read to something smaller than that - by a + safe margin, in case the limit depends on system + resources or version. */ + ret = ui_file_read (gdb_stdtargin, (char *) buffer, 16383); remote_fio_no_longjmp = 1; if (ret > 0 && (size_t)ret > length) {