From 5fb0ca0ddf59f49b49200128095fb2d4a1577020 Mon Sep 17 00:00:00 2001 From: tedu <> Date: Wed, 16 Apr 2014 19:42:24 +0000 Subject: > As I walk through the valley of the shadow of death > I take a look at my life and realize there's nothin' left > Cause I've been blasting and laughing so long, > That even my mama thinks that my mind is gone Remove even more unspeakable evil being perpetuated in the name of VMS. (and lesser evils done in the name of others.) ok miod --- src/lib/libcrypto/bio/b_sock.c | 269 +---------------------------------------- 1 file changed, 2 insertions(+), 267 deletions(-) (limited to 'src/lib/libcrypto/bio/b_sock.c') diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index cd62f889ab..3ccebf77f4 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c @@ -184,14 +184,7 @@ BIO_get_port(const char *str, unsigned short *port_ptr) *port_ptr = (unsigned short)i; else { CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME); - /* Note: under VMS with SOCKETSHR, it seems like the first - * parameter is 'char *', instead of 'const char *' - */ -#ifndef CONST_STRICT - s = getservbyname((char *)str, "tcp"); -#else s = getservbyname(str, "tcp"); -#endif if (s != NULL) *port_ptr = ntohs((unsigned short)s->s_port); CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); @@ -247,260 +240,24 @@ BIO_sock_error(int sock) return (j); } -#if 0 -long -BIO_ghbn_ctrl(int cmd, int iarg, char *parg) -{ - int i; - char **p; - - switch (cmd) { - case BIO_GHBN_CTRL_HITS: - return (BIO_ghbn_hits); - /* break; */ - case BIO_GHBN_CTRL_MISSES: - return (BIO_ghbn_miss); - /* break; */ - case BIO_GHBN_CTRL_CACHE_SIZE: - return (GHBN_NUM); - /* break; */ - case BIO_GHBN_CTRL_GET_ENTRY: - if ((iarg >= 0) && (iarg < GHBN_NUM) && - (ghbn_cache[iarg].order > 0)) { - p = (char **)parg; - if (p == NULL) - return (0); - *p = ghbn_cache[iarg].name; - ghbn_cache[iarg].name[128] = '\0'; - return (1); - } - return (0); - /* break; */ - case BIO_GHBN_CTRL_FLUSH: - for (i = 0; i < GHBN_NUM; i++) - ghbn_cache[i].order = 0; - break; - default: - return (0); - } - return (1); -} -#endif - -#if 0 -static struct hostent -*ghbn_dup(struct hostent *a) +struct hostent * +BIO_gethostbyname(const char *name) { - struct hostent *ret; - int i, j; - - MemCheck_off(); - ret = (struct hostent *)OPENSSL_malloc(sizeof(struct hostent)); - if (ret == NULL) - return (NULL); - memset(ret, 0, sizeof(struct hostent)); - - for (i = 0; a->h_aliases[i] != NULL; i++) - ; - i++; - ret->h_aliases = (char **)OPENSSL_malloc(i*sizeof(char *)); - if (ret->h_aliases == NULL) - goto err; - memset(ret->h_aliases, 0, i*sizeof(char *)); - - for (i = 0; a->h_addr_list[i] != NULL; i++) - ; - i++; - ret->h_addr_list = (char **)OPENSSL_malloc(i*sizeof(char *)); - if (ret->h_addr_list == NULL) - goto err; - memset(ret->h_addr_list, 0, i*sizeof(char *)); - - j = strlen(a->h_name) + 1; - if ((ret->h_name = OPENSSL_malloc(j)) == NULL) - goto err; - memcpy((char *)ret->h_name, a->h_name, j); - for (i = 0; a->h_aliases[i] != NULL; i++) { - j = strlen(a->h_aliases[i]) + 1; - if ((ret->h_aliases[i] = OPENSSL_malloc(j)) == NULL) - goto err; - memcpy(ret->h_aliases[i], a->h_aliases[i], j); - } - ret->h_length = a->h_length; - ret->h_addrtype = a->h_addrtype; - for (i = 0; a->h_addr_list[i] != NULL; i++) { - if ((ret->h_addr_list[i] = OPENSSL_malloc(a->h_length)) == NULL) - goto err; - memcpy(ret->h_addr_list[i], a->h_addr_list[i], a->h_length); - } - if (0) { -err: - if (ret != NULL) - ghbn_free(ret); - ret = NULL; - } - MemCheck_on(); - return (ret); -} - -static void -ghbn_free(struct hostent *a) -{ - int i; - - if (a == NULL) - return; - - if (a->h_aliases != NULL) { - for (i = 0; a->h_aliases[i] != NULL; i++) - OPENSSL_free(a->h_aliases[i]); - OPENSSL_free(a->h_aliases); - } - if (a->h_addr_list != NULL) { - for (i = 0; a->h_addr_list[i] != NULL; i++) - OPENSSL_free(a->h_addr_list[i]); - OPENSSL_free(a->h_addr_list); - } - if (a->h_name != NULL) - OPENSSL_free(a->h_name); - OPENSSL_free(a); -} - -#endif - -struct hostent -*BIO_gethostbyname(const char *name) -{ -#if 1 - /* Caching gethostbyname() results forever is wrong, - * so we have to let the true gethostbyname() worry about this */ -#if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__)) - return gethostbyname((char*)name); -#else return gethostbyname(name); -#endif -#else - struct hostent *ret; - int i, lowi = 0, j; - unsigned long low = (unsigned long) - 1; - - -# if 0 - /* It doesn't make sense to use locking here: The function interface - * is not thread-safe, because threads can never be sure when - * some other thread destroys the data they were given a pointer to. - */ - CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); -# endif - j = strlen(name); - if (j < 128) { - for (i = 0; i < GHBN_NUM; i++) { - if (low > ghbn_cache[i].order) { - low = ghbn_cache[i].order; - lowi = i; - } - if (ghbn_cache[i].order > 0) { - if (strncmp(name, ghbn_cache[i].name, 128) == 0) - break; - } - } - } else - i = GHBN_NUM; - - if (i == GHBN_NUM) /* no hit*/ - { - BIO_ghbn_miss++; - /* Note: under VMS with SOCKETSHR, it seems like the first - * parameter is 'char *', instead of 'const char *' - */ -# ifndef CONST_STRICT - ret = gethostbyname((char *)name); -# else - ret = gethostbyname(name); -# endif - - if (ret == NULL) - goto end; - if (j > 128) /* too big to cache */ - { -# if 0 - /* If we were trying to make this function thread-safe (which - * is bound to fail), we'd have to give up in this case - * (or allocate more memory). */ - ret = NULL; -# endif - goto end; - } - - /* else add to cache */ - if (ghbn_cache[lowi].ent != NULL) - ghbn_free(ghbn_cache[lowi].ent); /* XXX not thread-safe */ - ghbn_cache[lowi].name[0] = '\0'; - - if ((ret = ghbn_cache[lowi].ent = ghbn_dup(ret)) == NULL) { - BIOerr(BIO_F_BIO_GETHOSTBYNAME, ERR_R_MALLOC_FAILURE); - goto end; - } - strncpy(ghbn_cache[lowi].name, name, 128); - ghbn_cache[lowi].order = BIO_ghbn_miss + BIO_ghbn_hits; - } else { - BIO_ghbn_hits++; - ret = ghbn_cache[i].ent; - ghbn_cache[i].order = BIO_ghbn_miss + BIO_ghbn_hits; - } -end: -# if 0 - CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); -# endif - return (ret); -#endif } int BIO_sock_init(void) { -#ifdef WATT32 - extern int _watt_do_exit; - _watt_do_exit = 0; - /* don't make sock_init() call exit() */ - if (sock_init()) - return (-1); -#endif - -#if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) - WORD wVerReq; - WSADATA wsaData; - int err; - - if (!wsa_init_done) { - wsa_init_done = 1; - wVerReq = MAKEWORD( 2, 0 ); - err = WSAStartup(wVerReq, &wsaData); - if (err != 0) { - SYSerr(SYS_F_WSASTARTUP, err); - BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP); - return (-1); - } - } -#endif - return (1); } void BIO_sock_cleanup(void) { -#if defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK) - if (wsa_init_done) { - wsa_init_done = 0; - WSACleanup(); - } -#endif } -#if !defined(OPENSSL_SYS_VMS) || __VMS_VER >= 70000000 - int BIO_socket_ioctl(int fd, long type, void *arg) { @@ -509,28 +266,7 @@ BIO_socket_ioctl(int fd, long type, void *arg) #ifdef __DJGPP__ i = ioctl(fd, type, (char *)arg); #else -# if defined(OPENSSL_SYS_VMS) - /* 2011-02-18 SMS. - * VMS ioctl() can't tolerate a 64-bit "void *arg", but we - * observe that all the consumers pass in an "unsigned long *", - * so we arrange a local copy with a short pointer, and use - * that, instead. - */ -# if __INITIAL_POINTER_SIZE == 64 -# define ARG arg_32p -# pragma pointer_size save -# pragma pointer_size 32 - unsigned long arg_32; - unsigned long *arg_32p; -# pragma pointer_size restore - arg_32p = &arg_32; - arg_32 = *((unsigned long *) arg); -# else /* __INITIAL_POINTER_SIZE == 64 */ -# define ARG arg -# endif /* __INITIAL_POINTER_SIZE == 64 [else] */ -# else /* defined(OPENSSL_SYS_VMS) */ # define ARG arg -# endif /* defined(OPENSSL_SYS_VMS) [else] */ i = ioctl(fd, type, ARG); #endif /* __DJGPP__ */ @@ -538,7 +274,6 @@ BIO_socket_ioctl(int fd, long type, void *arg) SYSerr(SYS_F_IOCTLSOCKET, errno); return (i); } -#endif /* __VMS_VER */ /* The reason I have implemented this instead of using sscanf is because * Visual C 1.52c gives an unresolved external when linking a DLL :-( */ -- cgit v1.2.3-55-g6feb