Replace a few more str(n)dupa by str(n)dup + free

strdup and strndup still don't exist on bionic, so we need to do the
alloc() call ourselves or free the memory by hand.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>