bug-20755 - Changed strdup to strndup to avoid copying garbage in empty buffers