Why have you changed strlcpy() to strncpy() ?  Do you actively want to fail to truncate if username is too long ?  Do you actually care, when there is enough space, about filling all of the remaining space in the destination buffer with '\0' bytes that you're never going to look at ?  I think you only need one '\0' byte after the copied useful data, you don't need strncpy()'s memset of the rest of the buffer !