pac: Use strdup and asprintf in place of dubious string building
GCC 14 warned about transposed arguments to calloc, but these cases
are better served by more abstract string functions.
(cherry picked from commit f94513a3a36b50823c3918c93ee5c6bf5f525e91)