remove the duplicate strnlen and strndup