
...
Code Block |
---|
char src1[100] = "hello"; char src2[7] = {'g','o','o','d','b','y','e'}; char dst1[6], dst2[5]; int r1, r2; r1 = strcpy_s(dst1, 6, src1); r2 = strcpy_s(dst2, 5, src2); |
Wiki Markup |
---|
However, the call to copy {{src2}} to {{dst2}} fails because there is insufficient space available to copy the entire string, which consists of seven characters, to the destination buffer. As a result, {{r2}} is assigned a nonzero value and {{dst2 |
\[0\]}} is set to "\0." |
Users of the ISO/IEC TR 24731 functions are less likely to introduce a security flaw because the size of the destination buffer and the maximum number of characters to append must be specified. ISO/IEC TR 24731 functions also ensure null termination of the destination string.
...