thanks for the patch. Did you notice any breakage in the wild? I hesitate to include your change because that could actually break some configurations: in case HAVE_STRNLEN is not defined but strnlen is provided nonetheless linking would fail. Actually I'd be surprised if it would not make problems with other libc implementations.
NetBSD before 6.0 is definitely the one which breaks here, as well as other late adopters of srtnlen(), like FreeBSD before 8.0. Please feel free to NAK the patch if you think that the support of ancient libcs is not something to worry about (and old BSDs are definitely not LTS distros with ten-year support span).