mirror of https://github.com/xemu-project/xemu.git
buffer overflow fix - handle case where stdin is closed (Rusty Russell)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@397 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
a07cf92aed
commit
27c3f2cb9b
10
vl.c
10
vl.c
|
@ -3283,8 +3283,8 @@ CPUState *cpu_gdbstub_get_env(void *opaque)
|
||||||
|
|
||||||
int main_loop(void *opaque)
|
int main_loop(void *opaque)
|
||||||
{
|
{
|
||||||
struct pollfd ufds[2], *pf, *serial_ufd, *net_ufd, *gdb_ufd;
|
struct pollfd ufds[3], *pf, *serial_ufd, *net_ufd, *gdb_ufd;
|
||||||
int ret, n, timeout;
|
int ret, n, timeout, serial_ok;
|
||||||
uint8_t ch;
|
uint8_t ch;
|
||||||
CPUState *env = global_env;
|
CPUState *env = global_env;
|
||||||
|
|
||||||
|
@ -3296,6 +3296,7 @@ int main_loop(void *opaque)
|
||||||
term_init();
|
term_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serial_ok = 1;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ret = cpu_x86_exec(env);
|
ret = cpu_x86_exec(env);
|
||||||
if (reset_requested)
|
if (reset_requested)
|
||||||
|
@ -3310,7 +3311,7 @@ int main_loop(void *opaque)
|
||||||
/* poll any events */
|
/* poll any events */
|
||||||
serial_ufd = NULL;
|
serial_ufd = NULL;
|
||||||
pf = ufds;
|
pf = ufds;
|
||||||
if (!(serial_ports[0].lsr & UART_LSR_DR)) {
|
if (serial_ok && !(serial_ports[0].lsr & UART_LSR_DR)) {
|
||||||
serial_ufd = pf;
|
serial_ufd = pf;
|
||||||
pf->fd = 0;
|
pf->fd = 0;
|
||||||
pf->events = POLLIN;
|
pf->events = POLLIN;
|
||||||
|
@ -3337,6 +3338,9 @@ int main_loop(void *opaque)
|
||||||
n = read(0, &ch, 1);
|
n = read(0, &ch, 1);
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
serial_received_byte(&serial_ports[0], ch);
|
serial_received_byte(&serial_ports[0], ch);
|
||||||
|
} else {
|
||||||
|
/* Closed, stop polling. */
|
||||||
|
serial_ok = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (net_ufd && (net_ufd->revents & POLLIN)) {
|
if (net_ufd && (net_ufd->revents & POLLIN)) {
|
||||||
|
|
Loading…
Reference in New Issue