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

That argument sounds totally wrong because you can easily detect truncation:

    if (strlcpy(dst, src, dst_len) >= dst_len) {
      // Truncation!
    }


The argument is also totally wrong because the whole point of strlcpy is to copy the string and, if it fails, calculate the amount of storage that was really required, without making two passes over the data that does fit. The fact that the too-small buffer is overwritten with a truncated copy of a string is just a side effect.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: