`strncpy()` is a tricky little bastard. `n` it the maximum length of the **source**, but you want to limit the maximum length of the **destination**. And as `strlcpy()` is non-standard (and does not exists in my version of glibc), `snprintf(dest, sizeof (dest), "%s", source);` is the only option.