On Do, 2007-11-15 at 17:35 +0100, Stefan Dösinger wrote:
Is it really needed to check the memory after the end of the string? Does an application depend on this?
--- cut --- memset(dest, 'X', sizeof(dest)-1); /* never read past the buffer, when we check the result */ dest[sizeof(dest)-1] = '\0';
ret = pstrcpy_s(dest, sizeof(dest), small); ok( !ret && !lstrcmpA(dest, small), "got %d and '%s' (expected '0' and '%s')\n", ret, dest, small);
-- cut --
For my tests with buffers, i found it useful to test with: - buffer present, but size is 0 - buffer one byte smaller as the string (no space left for the '\0') - buffer large enough for the string, but no space left for the '\0' - buffer exact as needed - buffer one byte larger as needed - empty source string - NULL source - NULL target
This allow you to verify, how the terminating '\0' is handled.
Did you test with invalid pointers (crash / handled graceful)?
Am Freitag, 16. November 2007 00:45:47 schrieb Detlef Riekenberg:
It shows that the msdn documents the function incorrectly: It says the string is unmodified, which is apparently not the case.
Did you test with invalid pointers (crash / handled graceful)?
No, good idea, I'll try that now