Skip to contentSkip to conversation

Fix struct termios host - target translation

PATCH In review Arnaud Patard (Rtp) 2 participants 2 messages Apr 19, 2009 – Apr 20, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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).

---

linux-user/syscall.c +2 -0
index 2d51d6b..2d876c1 100644
@@ -2527,6 +2527,7 @@ static void target_to_host_termios (void *dst, const void *src)
         target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl);
     host->c_line = target->c_line;
 
+    memset(host->c_cc, 0, sizeof(host->c_cc));
     host->c_cc[VINTR] = target->c_cc[TARGET_VINTR];
     host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT];
     host->c_cc[VERASE] = target->c_cc[TARGET_VERASE];
@@ -2561,6 +2562,7 @@ static void host_to_target_termios (void *dst, const void *src)
         tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl));
     target->c_line = host->c_line;
 
+    memset(target->c_cc, 0, sizeof(target->c_cc));
     target->c_cc[TARGET_VINTR] = host->c_cc[VINTR];
     target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT];
     target->c_cc[TARGET_VERASE] = host->c_cc[VERASE];
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Arnaud Patard

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).

Looks correct to me, and can verify that stty now works better on arm/amd64 target/host combo.

Quoted 24 lines

---

linux-user/syscall.c +2 -0
index 2d51d6b..2d876c1 100644
@@ -2527,6 +2527,7 @@ static void target_to_host_termios (void *dst, const void *src)
         target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl);
     host->c_line = target->c_line;
 
+    memset(host->c_cc, 0, sizeof(host->c_cc));
     host->c_cc[VINTR] = target->c_cc[TARGET_VINTR];
     host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT];
     host->c_cc[VERASE] = target->c_cc[TARGET_VERASE];
@@ -2561,6 +2562,7 @@ static void host_to_target_termios (void *dst, const void *src)
         tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl));
     target->c_line = host->c_line;
 
+    memset(target->c_cc, 0, sizeof(target->c_cc));
     target->c_cc[TARGET_VINTR] = host->c_cc[VINTR];
     target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT];
     target->c_cc[TARGET_VERASE] = host->c_cc[VERASE];