Various bugfixes: Uses locking for some more of the stuff that is not
thread-safe (where thread-safe counterparts are not available on all
platforms), and don't memcpy to NULL-pointers
Submitted by: Anonymous
Reviewed by: Bodo Moeller

Also, clean up htons vs. ntohs confusions.
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index d601509..7808765 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -89,10 +89,12 @@
 	"rand",
 	"debug_malloc",
 	"BIO",
-	"bio_gethostbyname",
+	"gethostbyname",
+	"getservbyname",
+	"readdir",
 	"RSA_blinding",
-#if CRYPTO_NUM_LOCKS != 22
-# error "Inconsistency between crypto.h and cryptlic.c"
+#if CRYPTO_NUM_LOCKS != 24
+# error "Inconsistency between crypto.h and cryptlib.c"
 #endif
 	};