Return meaningful errno in overflow case; print error message to stderr in one more case.
Return meaningful errno in overflow case; print error message to stderr
in one more case.

Obtained from:	NetBSD via OpenBSD

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase