2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

ptrace_write_string: make sure we always write the terminating NUL.

We can't check *str for NUL since it may not have been written yet.
This commit is contained in:
Todd C. Miller 2022-05-10 11:23:44 -06:00
parent 8fe1238679
commit 6cd461d9f8

View File

@ -465,8 +465,10 @@ ptrace_write_string(pid_t pid, long addr, const char *str)
__func__, (int)pid, addr, (int)sizeof(u.buf), u.buf);
debug_return_size_t(-1);
}
if (*str == '\0')
if ((u.word & 0xff) == 0) {
/* If the last byte we wrote is a NUL we are done. */
debug_return_size_t(str - str0 + 1);
}
addr += sizeof(long);
}
}