News for hackers. Stuff that matters.
Re:Stop using strncpy already by IgorPartola on Thursday April 04, 2013 @07:24AM (#5492002)
So this safe function cannot be used with dynamically allocated buffers without casting them? That means it takes away the benefit of not passing in the size explicitly. It also does not deal with wide chars.

I think storing sizes explicitly is the better solution. If what you are dealing with are actually character strings, then you might store the byte size along with the char count.

If you are only dealing with ASCII (are you sure?), you could use memcpy and avoid the strncpy zero fill behavior.

There are no comments on this comment yet.