Hacker News new | past | comments | ask | show | jobs | submit login

Most people use sizeof when they are copying between static buffers on the stack. Strlen would be just as bad of an idea in this example because they're using the src buffer as the limit on the copy rather than the dst buffer which is still vulnerable to overflow. Should be:

strncpy(dst, src, sizeof(dst)-1);

Edit: bad code




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

Search: