_PW_NAME_LEN should be 32, not 31. The closing NUL is accounted for in username[].