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

Including this copyright is the right thing, but I believe our modifications should be separate commit. The original commit might be better to be a pristine copy, for both debugging and accounting reasons.