Change strdup() to strndup()