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:
@@ -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);
|
__func__, (int)pid, addr, (int)sizeof(u.buf), u.buf);
|
||||||
debug_return_size_t(-1);
|
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);
|
debug_return_size_t(str - str0 + 1);
|
||||||
|
}
|
||||||
addr += sizeof(long);
|
addr += sizeof(long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user