3 ms·
I don’t think that’s an accurate summary. “Use memcpy() instead. Use strncpy() in limited circumstances.”
by ajanuary 5y ago
I don’t think that’s an accurate summary. “Use memcpy() instead. Use strncpy() in limited circumstances.”
- icedchai 5y agoDoesn'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_strncpy.c https://github.com/brgl/busybox/blob/master/libbb/safe_strnc...