Redmine #5211: Detect broken strndup on AIX and provide workaround.

It is a separate commit. :-)