|
|
|
|
|
by vardump
2853 days ago
|
|
Perhaps because the memory buffers might be of different size. Maybe memcpy_oobp (out of bounds protection) signature could be: memcpy_oobp(void* dst, size_t dst_size, void* src, size_t src_size);
Then again, I guess you could just as well do: memcpy(dst, src, min(dst_size, src_size));
But having to explicitly specify both destination and source sizes might have prevented a lot of buffer overwrite bugs. |
|
A good way to prevent this is to have a buffer abstraction, where the size is a property of the type, e.g.,
Of course, it doesn't prevent people from using memcpy directly.