|
|
|
|
|
by rwmj
2853 days ago
|
|
> He asked: why is there no argument to memcpy() to specify the maximum destination length? I'm confused by this. The third argument provides the destination length, so what good would a "maximum destination length" do? I guess he must mean that because the length is often computed, you'd need a fourth argument to ensure the length isn't greater than some sane upper bound. But you can easily fix that using an if statement around the memcpy. |
|
Maybe memcpy_oobp (out of bounds protection) signature could be:
Then again, I guess you could just as well do: But having to explicitly specify both destination and source sizes might have prevented a lot of buffer overwrite bugs.