Replace strndup with strncpy in targetName

strndup is not standard for all systems, in particular it is not
available on Mac OS (at least as of 10.6.8, the one I'm using). This
patch replaces the use of strndup in targetName with strncpy.

Intended to fix issue #9.