Commit 44607123c4f8393b9fcbbb63274f5f9dcbeaae21

Authored by Arnaud Patard
Committed by Riku Voipio
1 parent ebc996f3

Fix struct termios host - target translation

When converting the termios structure between host and target in
target_to_host_termios and host_to_target_termios, the c_cc[] array is
never initialised.
Calling memset() before using it allows to run successfully "stty echo /
stty -echo" on arm-linux-user target (host being x86 and mips).

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Showing 1 changed file with 2 additions and 0 deletions
linux-user/syscall.c
@@ -2977,6 +2977,7 @@ static void target_to_host_termios (void *dst, const void *src) @@ -2977,6 +2977,7 @@ static void target_to_host_termios (void *dst, const void *src)
2977 target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl); 2977 target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl);
2978 host->c_line = target->c_line; 2978 host->c_line = target->c_line;
2979 2979
  2980 + memset(host->c_cc, 0, sizeof(host->c_cc));
2980 host->c_cc[VINTR] = target->c_cc[TARGET_VINTR]; 2981 host->c_cc[VINTR] = target->c_cc[TARGET_VINTR];
2981 host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT]; 2982 host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT];
2982 host->c_cc[VERASE] = target->c_cc[TARGET_VERASE]; 2983 host->c_cc[VERASE] = target->c_cc[TARGET_VERASE];
@@ -3011,6 +3012,7 @@ static void host_to_target_termios (void *dst, const void *src) @@ -3011,6 +3012,7 @@ static void host_to_target_termios (void *dst, const void *src)
3011 tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl)); 3012 tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl));
3012 target->c_line = host->c_line; 3013 target->c_line = host->c_line;
3013 3014
  3015 + memset(target->c_cc, 0, sizeof(target->c_cc));
3014 target->c_cc[TARGET_VINTR] = host->c_cc[VINTR]; 3016 target->c_cc[TARGET_VINTR] = host->c_cc[VINTR];
3015 target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT]; 3017 target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT];
3016 target->c_cc[TARGET_VERASE] = host->c_cc[VERASE]; 3018 target->c_cc[TARGET_VERASE] = host->c_cc[VERASE];