Skip to content

Commit

Permalink
arm-semi: don't leak 1KB user string lock buffer upon TARGET_SYS_OPEN
Browse files Browse the repository at this point in the history
Always call unlock_user before returning.

Signed-off-by: Jim Meyering <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
Jim Meyering authored and Anthony Liguori committed Aug 22, 2012
1 parent a7e47d4 commit 396bef4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions target-arm/arm-semi.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,19 @@ uint32_t do_arm_semihosting(CPUARMState *env)
if (!(s = lock_user_string(ARG(0))))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
if (ARG(1) >= 12)
if (ARG(1) >= 12) {
unlock_user(s, ARG(0), 0);
return (uint32_t)-1;
}
if (strcmp(s, ":tt") == 0) {
if (ARG(1) < 4)
return STDIN_FILENO;
else
return STDOUT_FILENO;
int result_fileno = ARG(1) < 4 ? STDIN_FILENO : STDOUT_FILENO;
unlock_user(s, ARG(0), 0);
return result_fileno;
}
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "open,%s,%x,1a4", ARG(0),
(int)ARG(2)+1, gdb_open_modeflags[ARG(1)]);
return env->regs[0];
ret = env->regs[0];
} else {
ret = set_swi_errno(ts, open(s, open_modeflags[ARG(1)], 0644));
}
Expand Down

0 comments on commit 396bef4

Please sign in to comment.