- uri is expected to be nul-terminated (strchr used later), so use strlcpy instead of strncpy. - replace the other two cases of strncpy+\0 with strlcpy.