Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don’t think that’s an accurate summary. “Use memcpy() instead. Use strncpy() in limited circumstances.”


Doesn't memcpy have the same issue as strncpy? the destination will not be null terminated if the source is too long.

Many projects just implement a safe_strncpy wrapper that always terminates the destination. Example: https://github.com/brgl/busybox/blob/master/libbb/safe_strnc...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: