Skip to content

Commit

Permalink
lgblgblgb#220: Fixed a prob with overflow of hypervisor_monout buffer…
Browse files Browse the repository at this point in the history
… for mega65_ftp actions like 'get MYDISK.D81'.
  • Loading branch information
Gurce Isikyildiz authored and gurcei committed May 15, 2024
1 parent 96fc647 commit 2886cd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion targets/mega65/hypervisor.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,13 @@ void hypervisor_serial_monitor_push_char ( Uint8 chr )
if (hypervisor_serial_output_fd >= 0 && write(hypervisor_serial_output_fd, &chr, 1) != 1)
hypervisor_serial_output_errors++;
if (hypervisor_monout_p >= hypervisor_monout - 1 + sizeof hypervisor_monout)
return;
{
// NOTE: For long mega65_ftp actions like 'get MYDISK.D81`, a lot of
// serial chars will be sent that are raw binary, and there's a good chance
// it could overflow the 'hypervisor_monout' buffer.
// So in such cases, I'll simply empty hypervisor_monout.
hypervisor_monout_p = hypervisor_monout;
}
int flush = (chr == 0x0A || chr == 0x0D || chr == 0x8A || chr == 0x8D);
write_hypervisor_byte(chr);
if (hypervisor_monout_p == hypervisor_monout && flush)
Expand Down
2 changes: 1 addition & 1 deletion targets/mega65/uart_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void read_from_socket(comms_details_type *cd)
while(cd->umon_read_buffer[cd->umon_read_pos+i] != 0)
{
int pos = cd->umon_read_pos + i;
if (cd->umon_read_buffer[pos]>=' ') printf("%c",cd->umon_read_buffer[pos]); else printf("[$%02X]",cd->umon_read_buffer[pos]);
if (cd->umon_read_buffer[pos]>=' ') printf("%c",cd->umon_read_buffer[pos]); else printf("[$%02X]",(unsigned char)cd->umon_read_buffer[pos]);
i++;
}
printf("\n");
Expand Down

0 comments on commit 2886cd2

Please sign in to comment.