X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=crypto%2Fbio%2Fbss_acpt.c;h=e3b88504a37748606510ef185cdf46be89b2fcda;hb=b00b21242ae96aeb5521252bf0cdece5be0047a1;hp=b514d9e394996aafed6ce18cdc4abc4577a84da1;hpb=0f113f3ee4d629ef9a4a30911b22b224772085e5;p=openssl.git diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index b514d9e394..e3b88504a3 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -1,4 +1,3 @@ -/* crypto/bio/bss_acpt.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -59,11 +58,17 @@ #include #include #define USE_SOCKETS -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #ifndef OPENSSL_NO_SOCK +/* + * We are currently using deprecated functions here, and GCC warns + * us about them, but since we know, we don't want to hear it. + */ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + # if (defined(OPENSSL_SYS_VMS) && __VMS_VER < 70000000) /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ # undef FIONBIO @@ -123,7 +128,7 @@ static int acpt_new(BIO *bi) BIO_ACCEPT *ba; bi->init = 0; - bi->num = INVALID_SOCKET; + bi->num = (int)INVALID_SOCKET; bi->flags = 0; if ((ba = BIO_ACCEPT_new()) == NULL) return (0); @@ -137,11 +142,9 @@ static BIO_ACCEPT *BIO_ACCEPT_new(void) { BIO_ACCEPT *ret; - if ((ret = (BIO_ACCEPT *)OPENSSL_malloc(sizeof(BIO_ACCEPT))) == NULL) + if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) return (NULL); - - memset(ret, 0, sizeof(BIO_ACCEPT)); - ret->accept_sock = INVALID_SOCKET; + ret->accept_sock = (int)INVALID_SOCKET; ret->bind_mode = BIO_BIND_NORMAL; return (ret); } @@ -151,12 +154,9 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a) if (a == NULL) return; - if (a->param_addr != NULL) - OPENSSL_free(a->param_addr); - if (a->addr != NULL) - OPENSSL_free(a->addr); - if (a->bio_chain != NULL) - BIO_free(a->bio_chain); + OPENSSL_free(a->param_addr); + OPENSSL_free(a->addr); + BIO_free(a->bio_chain); OPENSSL_free(a); } @@ -165,11 +165,11 @@ static void acpt_close_socket(BIO *bio) BIO_ACCEPT *c; c = (BIO_ACCEPT *)bio->ptr; - if (c->accept_sock != INVALID_SOCKET) { + if (c->accept_sock != (int)INVALID_SOCKET) { shutdown(c->accept_sock, 2); closesocket(c->accept_sock); - c->accept_sock = INVALID_SOCKET; - bio->num = INVALID_SOCKET; + c->accept_sock = (int)INVALID_SOCKET; + bio->num = (int)INVALID_SOCKET; } } @@ -205,7 +205,7 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) return (-1); } s = BIO_get_accept_socket(c->param_addr, c->bind_mode); - if (s == INVALID_SOCKET) + if (s == (int)INVALID_SOCKET) return (-1); if (c->accept_nbio) { @@ -354,14 +354,12 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) if (ptr != NULL) { if (num == 0) { b->init = 1; - if (data->param_addr != NULL) - OPENSSL_free(data->param_addr); - data->param_addr = BUF_strdup(ptr); + OPENSSL_free(data->param_addr); + data->param_addr = OPENSSL_strdup(ptr); } else if (num == 1) { data->accept_nbio = (ptr != NULL); } else if (num == 2) { - if (data->bio_chain != NULL) - BIO_free(data->bio_chain); + BIO_free(data->bio_chain); data->bio_chain = (BIO *)ptr; } } @@ -415,12 +413,12 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) ret = (long)data->bind_mode; break; case BIO_CTRL_DUP: -/*- dbio=(BIO *)ptr; - if (data->param_port) EAY EAY - BIO_set_port(dbio,data->param_port); - if (data->param_hostname) - BIO_set_hostname(dbio,data->param_hostname); - BIO_set_nbio(dbio,data->nbio); */ +/*- dbio=(BIO *)ptr; + if (data->param_port) EAY EAY + BIO_set_port(dbio,data->param_port); + if (data->param_hostname) + BIO_set_hostname(dbio,data->param_hostname); + BIO_set_nbio(dbio,data->nbio); */ break; default: @@ -448,10 +446,8 @@ BIO *BIO_new_accept(const char *str) return (NULL); if (BIO_set_accept_port(ret, str)) return (ret); - else { - BIO_free(ret); - return (NULL); - } + BIO_free(ret); + return (NULL); } #endif