Add protections around the various system limits to protect code on unusual systems

Thanks to Paul Hargrove for reporting it on OpenBSD-5

cmr=v1.7.4:reviewer=jsquyres