Fix stack corruption due to calling convention mismatch

Standard library implementations may specify calling convention for memcpy
explicitly. However, the cbor* APIs don't do that. If you compile the lib
with default calling convention that doesn't match the calling convention o
memcpy(), the iterate_string_chunks() will not setup the stack for memcpy()
call correctly resulting in a stack corruption. The compiler doesn't catch
this issue because of the cast that is being applied when passing memcpy()
to the iterate_string_chunks().

The fix is to wrap memcpy() in a function that conforms to the declaration o
the IterateFunction which does two things, removes the need for a cast and
uncouples memcpy() calling convention from the rest of the cbor* APIs.

Signed-off-by: Alex Radutskiy (alex.radutskiy@microsoft.com)
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
1 file changed