mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-17 03:07:27 +00:00
strncpy_s(d, dmax, s, slen): the 'dmax' includes the null terminator, while slen doesn't. Thus if (dmax == slen == strlen(s)), strncpy_s() chooses to discard the last character from s and instead write '\0' to d[dmax - 1]. strnlen_s(s, maxsize): if there is no terminating null character in the first maxsize characters pointed to by s, strnlen_s() returns maxsize. So in the following example or similar cases, we need to increase the size of d[] by 1 to accommodate the null terminator, and add '1' to the dmax argument to strncpy_s(). uint8_t d[MAX_LEN]; size = strnlen_s(s, MAX_LEN); strncpy_s(d, MAX_LEN, s, size); Tracked-On: #861 Signed-off-by: Zide Chen <zide.chen@intel.com> |
||
---|---|---|
.. | ||
console.c | ||
dbg_cmd.c | ||
dump.c | ||
hypercall.c | ||
logmsg.c | ||
Makefile | ||
npk_log.c | ||
printf.c | ||
profiling.c | ||
sbuf.c | ||
shell_priv.h | ||
shell.c | ||
string.c | ||
trace.c | ||
uart16550.c | ||
vuart.c |