mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
AppleM1: Update openssl to v1.1.1l
This commit is contained in:
parent
1fe12b8e8c
commit
b787656eea
990 changed files with 13406 additions and 18710 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -7,10 +7,14 @@
|
|||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
@ -22,7 +26,7 @@ CRYPTO_RWLOCK *bio_lookup_lock;
|
|||
static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT;
|
||||
|
||||
/*
|
||||
* Throughout this file and bio_lcl.h, the existence of the macro
|
||||
* Throughout this file and bio_local.h, the existence of the macro
|
||||
* AI_PASSIVE is used to detect the availability of struct addrinfo,
|
||||
* getnameinfo() and getaddrinfo(). If that macro doesn't exist,
|
||||
* we use our own implementation instead, using gethostbyname,
|
||||
|
@ -675,7 +679,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
|||
|
||||
if (1) {
|
||||
#ifdef AI_PASSIVE
|
||||
int gai_ret = 0;
|
||||
int gai_ret = 0, old_ret = 0;
|
||||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
|
@ -683,26 +687,48 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
|||
hints.ai_family = family;
|
||||
hints.ai_socktype = socktype;
|
||||
hints.ai_protocol = protocol;
|
||||
# ifdef AI_ADDRCONFIG
|
||||
# ifdef AF_UNSPEC
|
||||
if (host != NULL && family == AF_UNSPEC)
|
||||
# endif
|
||||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
# endif
|
||||
|
||||
if (lookup_type == BIO_LOOKUP_SERVER)
|
||||
hints.ai_flags |= AI_PASSIVE;
|
||||
|
||||
/* Note that |res| SHOULD be a 'struct addrinfo **' thanks to
|
||||
* macro magic in bio_lcl.h
|
||||
* macro magic in bio_local.h
|
||||
*/
|
||||
# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST)
|
||||
retry:
|
||||
# endif
|
||||
switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
|
||||
# ifdef EAI_SYSTEM
|
||||
case EAI_SYSTEM:
|
||||
SYSerr(SYS_F_GETADDRINFO, get_last_socket_error());
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
break;
|
||||
# endif
|
||||
# ifdef EAI_MEMORY
|
||||
case EAI_MEMORY:
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
|
||||
break;
|
||||
# endif
|
||||
case 0:
|
||||
ret = 1; /* Success */
|
||||
break;
|
||||
default:
|
||||
# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST)
|
||||
if (hints.ai_flags & AI_ADDRCONFIG) {
|
||||
hints.ai_flags &= ~AI_ADDRCONFIG;
|
||||
hints.ai_flags |= AI_NUMERICHOST;
|
||||
old_ret = gai_ret;
|
||||
goto retry;
|
||||
}
|
||||
# endif
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
ERR_add_error_data(1, gai_strerror(gai_ret));
|
||||
ERR_add_error_data(1, gai_strerror(old_ret ? old_ret : gai_ret));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
|
||||
#define DUMP_WIDTH 16
|
||||
#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4))
|
||||
|
@ -36,8 +36,8 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
|
|||
|
||||
if (indent < 0)
|
||||
indent = 0;
|
||||
else if (indent > 128)
|
||||
indent = 128;
|
||||
else if (indent > 64)
|
||||
indent = 64;
|
||||
|
||||
dump_width = DUMP_WIDTH_LESS_INDENT(indent);
|
||||
rows = len / dump_width;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/ctype.h"
|
||||
#include "crypto/ctype.h"
|
||||
#include "internal/numbers.h"
|
||||
#include <openssl/bio.h>
|
||||
|
||||
|
@ -635,7 +635,11 @@ fmtfp(char **sbuffer,
|
|||
fvalue = tmpvalue;
|
||||
}
|
||||
ufvalue = abs_val(fvalue);
|
||||
if (ufvalue > ULONG_MAX) {
|
||||
/*
|
||||
* By subtracting 65535 (2^16-1) we cancel the low order 15 bits
|
||||
* of ULONG_MAX to avoid using imprecise floating point values.
|
||||
*/
|
||||
if (ufvalue >= (double)(ULONG_MAX - 65535) + 65536.0) {
|
||||
/* Number too big */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
# define SOCKET_PROTOCOL IPPROTO_TCP
|
||||
# ifdef SO_MAXCONN
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -11,7 +11,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
@ -243,7 +243,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
|||
}
|
||||
}
|
||||
|
||||
# ifdef IPV6_V6ONLY
|
||||
/* On OpenBSD it is always ipv6 only with ipv6 sockets thus read-only */
|
||||
# if defined(IPV6_V6ONLY) && !defined(__OpenBSD__)
|
||||
if (BIO_ADDR_family(addr) == AF_INET6) {
|
||||
/*
|
||||
* Note: Windows default of IPV6_V6ONLY is ON, and Linux is OFF.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
static int buffer_write(BIO *h, const char *buf, int num);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/rand.h>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
* For clarity, we check for internal/cryptlib.h since it's a common header
|
||||
* that also includes bio.h.
|
||||
*/
|
||||
# ifdef HEADER_CRYPTLIB_H
|
||||
# error internal/cryptlib.h included before bio_lcl.h
|
||||
# ifdef OSSL_INTERNAL_CRYPTLIB_H
|
||||
# error internal/cryptlib.h included before bio_local.h
|
||||
# endif
|
||||
# ifdef HEADER_BIO_H
|
||||
# error openssl/bio.h included before bio_lcl.h
|
||||
# error openssl/bio.h included before bio_local.h
|
||||
# endif
|
||||
|
||||
/*
|
|
@ -7,7 +7,7 @@
|
|||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/thread_once.h"
|
||||
|
||||
CRYPTO_RWLOCK *bio_type_lock = NULL;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
||||
|
@ -222,10 +222,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
|
|||
break;
|
||||
|
||||
case ACPT_S_CREATE_SOCKET:
|
||||
ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (ret == (int)INVALID_SOCKET) {
|
||||
s = BIO_socket(BIO_ADDRINFO_family(c->addr_iter),
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (s == (int)INVALID_SOCKET) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_addr,
|
||||
|
@ -233,9 +233,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
|
|||
BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto exit_loop;
|
||||
}
|
||||
c->accept_sock = ret;
|
||||
b->num = ret;
|
||||
c->accept_sock = s;
|
||||
b->num = s;
|
||||
c->state = ACPT_S_LISTEN;
|
||||
s = -1;
|
||||
break;
|
||||
|
||||
case ACPT_S_LISTEN:
|
||||
|
@ -433,8 +434,10 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
b->init = 1;
|
||||
} else if (num == 1) {
|
||||
OPENSSL_free(data->param_serv);
|
||||
data->param_serv = BUF_strdup(ptr);
|
||||
b->init = 1;
|
||||
if ((data->param_serv = OPENSSL_strdup(ptr)) == NULL)
|
||||
ret = 0;
|
||||
else
|
||||
b->init = 1;
|
||||
} else if (num == 2) {
|
||||
data->bind_mode |= BIO_SOCK_NONBLOCK;
|
||||
} else if (num == 3) {
|
||||
|
@ -527,7 +530,12 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
break;
|
||||
|
||||
case BIO_CTRL_EOF:
|
||||
if (b->next_bio == NULL)
|
||||
ret = 0;
|
||||
else
|
||||
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
||||
|
@ -54,6 +54,7 @@ void BIO_CONNECT_free(BIO_CONNECT *a);
|
|||
#define BIO_CONN_S_CONNECT 4
|
||||
#define BIO_CONN_S_OK 5
|
||||
#define BIO_CONN_S_BLOCKED_CONNECT 6
|
||||
#define BIO_CONN_S_CONNECT_ERROR 7
|
||||
|
||||
static const BIO_METHOD methods_connectp = {
|
||||
BIO_TYPE_CONNECT,
|
||||
|
@ -174,7 +175,8 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
|||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
|
||||
c->state = BIO_CONN_S_CONNECT_ERROR;
|
||||
break;
|
||||
}
|
||||
goto exit_loop;
|
||||
} else {
|
||||
|
@ -184,8 +186,17 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
|||
|
||||
case BIO_CONN_S_BLOCKED_CONNECT:
|
||||
i = BIO_sock_error(b->num);
|
||||
if (i) {
|
||||
if (i != 0) {
|
||||
BIO_clear_retry_flags(b);
|
||||
if ((c->addr_iter = BIO_ADDRINFO_next(c->addr_iter)) != NULL) {
|
||||
/*
|
||||
* if there are more addresses to try, do that first
|
||||
*/
|
||||
BIO_closesocket(b->num);
|
||||
c->state = BIO_CONN_S_CREATE_SOCKET;
|
||||
ERR_clear_error();
|
||||
break;
|
||||
}
|
||||
SYSerr(SYS_F_CONNECT, i);
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
|
@ -197,6 +208,11 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
|||
c->state = BIO_CONN_S_OK;
|
||||
break;
|
||||
|
||||
case BIO_CONN_S_CONNECT_ERROR:
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
|
||||
ret = 0;
|
||||
goto exit_loop;
|
||||
|
||||
case BIO_CONN_S_OK:
|
||||
ret = 1;
|
||||
goto exit_loop;
|
||||
|
@ -309,6 +325,8 @@ static int conn_read(BIO *b, char *out, int outl)
|
|||
if (ret <= 0) {
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
else if (ret == 0)
|
||||
b->flags |= BIO_FLAGS_IN_EOF;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -398,12 +416,13 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
case BIO_C_SET_CONNECT:
|
||||
if (ptr != NULL) {
|
||||
b->init = 1;
|
||||
if (num == 0) {
|
||||
if (num == 0) { /* BIO_set_conn_hostname */
|
||||
char *hold_service = data->param_service;
|
||||
/* We affect the hostname regardless. However, the input
|
||||
* string might contain a host:service spec, so we must
|
||||
* parse it, which might or might not affect the service
|
||||
*/
|
||||
|
||||
OPENSSL_free(data->param_hostname);
|
||||
data->param_hostname = NULL;
|
||||
ret = BIO_parse_hostserv(ptr,
|
||||
|
@ -412,19 +431,29 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
BIO_PARSE_PRIO_HOST);
|
||||
if (hold_service != data->param_service)
|
||||
OPENSSL_free(hold_service);
|
||||
} else if (num == 1) {
|
||||
} else if (num == 1) { /* BIO_set_conn_port */
|
||||
OPENSSL_free(data->param_service);
|
||||
data->param_service = BUF_strdup(ptr);
|
||||
} else if (num == 2) {
|
||||
if ((data->param_service = OPENSSL_strdup(ptr)) == NULL)
|
||||
ret = 0;
|
||||
} else if (num == 2) { /* BIO_set_conn_address */
|
||||
const BIO_ADDR *addr = (const BIO_ADDR *)ptr;
|
||||
char *host = BIO_ADDR_hostname_string(addr, 1);
|
||||
char *service = BIO_ADDR_service_string(addr, 1);
|
||||
|
||||
ret = host != NULL && service != NULL;
|
||||
if (ret) {
|
||||
data->param_hostname = BIO_ADDR_hostname_string(addr, 1);
|
||||
data->param_service = BIO_ADDR_service_string(addr, 1);
|
||||
OPENSSL_free(data->param_hostname);
|
||||
data->param_hostname = host;
|
||||
OPENSSL_free(data->param_service);
|
||||
data->param_service = service;
|
||||
BIO_ADDRINFO_free(data->addr_first);
|
||||
data->addr_first = NULL;
|
||||
data->addr_iter = NULL;
|
||||
} else {
|
||||
OPENSSL_free(host);
|
||||
OPENSSL_free(service);
|
||||
}
|
||||
} else if (num == 3) {
|
||||
} else if (num == 3) { /* BIO_set_conn_ip_family */
|
||||
data->connect_family = *(int *)ptr;
|
||||
} else {
|
||||
ret = 0;
|
||||
|
@ -488,6 +517,9 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
*fptr = data->info_callback;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2005-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#ifndef OPENSSL_NO_DGRAM
|
||||
|
||||
# ifndef OPENSSL_NO_SCTP
|
||||
|
@ -784,7 +784,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
* reasons. When BIO_CTRL_DGRAM_SET_PEEK_MODE was first defined its value
|
||||
* was incorrectly clashing with BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE. The
|
||||
* value has been updated to a non-clashing value. However to preserve
|
||||
* binary compatiblity we now respond to both the old value and the new one
|
||||
* binary compatibility we now respond to both the old value and the new one
|
||||
*/
|
||||
case BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE:
|
||||
case BIO_CTRL_DGRAM_SET_PEEK_MODE:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -10,7 +10,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
|
||||
#if defined(OPENSSL_NO_POSIX_IO)
|
||||
/*
|
||||
|
@ -123,6 +123,8 @@ static int fd_read(BIO *b, char *out, int outl)
|
|||
if (ret <= 0) {
|
||||
if (BIO_fd_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
else if (ret == 0)
|
||||
b->flags |= BIO_FLAGS_IN_EOF;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -186,6 +188,9 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
case BIO_CTRL_FLUSH:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BSS_FILE_C
|
||||
# define HEADER_BSS_FILE_C
|
||||
|
||||
# if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
#if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
/*
|
||||
* Following definition aliases fopen to fopen64 on above mentioned
|
||||
* platforms. This makes it possible to open and sequentially access files
|
||||
|
@ -23,17 +20,17 @@
|
|||
* of 32-bit platforms which allow for sequential access of large files
|
||||
* without extra "magic" comprise *BSD, Darwin, IRIX...
|
||||
*/
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include "bio_lcl.h"
|
||||
# include <openssl/err.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_local.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
# if !defined(OPENSSL_NO_STDIO)
|
||||
#if !defined(OPENSSL_NO_STDIO)
|
||||
|
||||
static int file_write(BIO *h, const char *buf, int num);
|
||||
static int file_read(BIO *h, char *buf, int size);
|
||||
|
@ -72,9 +69,9 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
|||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
|
||||
if (errno == ENOENT
|
||||
# ifdef ENXIO
|
||||
#ifdef ENXIO
|
||||
|| errno == ENXIO
|
||||
# endif
|
||||
#endif
|
||||
)
|
||||
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
|
||||
else
|
||||
|
@ -212,33 +209,33 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
b->ptr = ptr;
|
||||
b->init = 1;
|
||||
# if BIO_FLAGS_UPLINK!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
# if BIO_FLAGS_UPLINK!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
/* Safety net to catch purely internal BIO_set_fp calls */
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
if (ptr == stdin || ptr == stdout || ptr == stderr)
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK);
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
if ((size_t)ptr >= (size_t)stdin &&
|
||||
(size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK);
|
||||
# endif
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
if (b->flags & BIO_FLAGS_UPLINK)
|
||||
UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));
|
||||
else
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
int fd = _fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd, _O_TEXT);
|
||||
else
|
||||
_setmode(fd, _O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
/* Set correct text/binary mode */
|
||||
if (num & BIO_FP_TEXT)
|
||||
|
@ -251,11 +248,11 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
} else
|
||||
_setmode(fd, _O_BINARY);
|
||||
}
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
setmode(fd, O_BINARY);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
|
@ -277,15 +274,15 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
ret = 0;
|
||||
break;
|
||||
}
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
else
|
||||
OPENSSL_strlcat(p, "t", sizeof(p));
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
# endif
|
||||
# endif
|
||||
fp = openssl_fopen(ptr, p);
|
||||
if (fp == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
|
@ -422,6 +419,4 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
# endif /* OPENSSL_NO_STDIO */
|
||||
|
||||
#endif /* HEADER_BSS_FILE_C */
|
||||
#endif /* OPENSSL_NO_STDIO */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
#if defined(OPENSSL_SYS_WINCE)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
static int mem_write(BIO *h, const char *buf, int num);
|
||||
|
@ -57,7 +57,12 @@ static const BIO_METHOD secmem_method = {
|
|||
NULL, /* mem_callback_ctrl */
|
||||
};
|
||||
|
||||
/* BIO memory stores buffer and read pointer */
|
||||
/*
|
||||
* BIO memory stores buffer and read pointer
|
||||
* however the roles are different for read only BIOs.
|
||||
* In that case the readp just stores the original state
|
||||
* to be used for reset.
|
||||
*/
|
||||
typedef struct bio_buf_mem_st {
|
||||
struct buf_mem_st *buf; /* allocated buffer */
|
||||
struct buf_mem_st *readp; /* read pointer */
|
||||
|
@ -192,11 +197,14 @@ static int mem_read(BIO *b, char *out, int outl)
|
|||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
|
||||
BUF_MEM *bm = bbm->readp;
|
||||
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
bm = bbm->buf;
|
||||
BIO_clear_retry_flags(b);
|
||||
ret = (outl >= 0 && (size_t)outl > bm->length) ? (int)bm->length : outl;
|
||||
if ((out != NULL) && (ret > 0)) {
|
||||
memcpy(out, bm->data, ret);
|
||||
bm->length -= ret;
|
||||
bm->max -= ret;
|
||||
bm->data += ret;
|
||||
} else if (bm->length == 0) {
|
||||
ret = b->num;
|
||||
|
@ -241,29 +249,34 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)b->ptr;
|
||||
BUF_MEM *bm;
|
||||
|
||||
if (b->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
bm = bbm->buf;
|
||||
else
|
||||
bm = bbm->readp;
|
||||
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
bm = bbm->buf;
|
||||
if (bm->data != NULL) {
|
||||
/* For read only case reset to the start again */
|
||||
if ((b->flags & BIO_FLAGS_MEM_RDONLY) || (b->flags & BIO_FLAGS_NONCLEAR_RST)) {
|
||||
bm->length = bm->max;
|
||||
if (!(b->flags & BIO_FLAGS_MEM_RDONLY)) {
|
||||
if (!(b->flags & BIO_FLAGS_NONCLEAR_RST)) {
|
||||
memset(bm->data, 0, bm->max);
|
||||
bm->length = 0;
|
||||
}
|
||||
*bbm->readp = *bbm->buf;
|
||||
} else {
|
||||
memset(bm->data, 0, bm->max);
|
||||
bm->length = 0;
|
||||
/* For read only case just reset to the start again */
|
||||
*bbm->buf = *bbm->readp;
|
||||
}
|
||||
*bbm->readp = *bbm->buf;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
bm = bbm->readp;
|
||||
ret = (long)(bm->length == 0);
|
||||
break;
|
||||
case BIO_C_SET_BUF_MEM_EOF_RETURN:
|
||||
b->num = (int)num;
|
||||
break;
|
||||
case BIO_CTRL_INFO:
|
||||
bm = bbm->readp;
|
||||
ret = (long)bm->length;
|
||||
if (ptr != NULL) {
|
||||
pptr = (char **)ptr;
|
||||
|
@ -278,8 +291,9 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
break;
|
||||
case BIO_C_GET_BUF_MEM_PTR:
|
||||
if (ptr != NULL) {
|
||||
mem_buf_sync(b);
|
||||
bm = bbm->readp;
|
||||
if (!(b->flags & BIO_FLAGS_MEM_RDONLY))
|
||||
mem_buf_sync(b);
|
||||
bm = bbm->buf;
|
||||
pptr = (char **)ptr;
|
||||
*pptr = (char *)bm;
|
||||
}
|
||||
|
@ -294,7 +308,6 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
ret = 0L;
|
||||
break;
|
||||
case BIO_CTRL_PENDING:
|
||||
bm = bbm->readp;
|
||||
ret = (long)bm->length;
|
||||
break;
|
||||
case BIO_CTRL_DUP:
|
||||
|
@ -318,6 +331,8 @@ static int mem_gets(BIO *bp, char *buf, int size)
|
|||
BIO_BUF_MEM *bbm = (BIO_BUF_MEM *)bp->ptr;
|
||||
BUF_MEM *bm = bbm->readp;
|
||||
|
||||
if (bp->flags & BIO_FLAGS_MEM_RDONLY)
|
||||
bm = bbm->buf;
|
||||
BIO_clear_retry_flags(bp);
|
||||
j = bm->length;
|
||||
if ((size - 1) < j)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
static int null_write(BIO *h, const char *buf, int num);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include "bio_local.h"
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
|
@ -101,6 +101,8 @@ static int sock_read(BIO *b, char *out, int outl)
|
|||
if (ret <= 0) {
|
||||
if (BIO_sock_should_retry(ret))
|
||||
BIO_set_retry_read(b);
|
||||
else if (ret == 0)
|
||||
b->flags |= BIO_FLAGS_IN_EOF;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -151,6 +153,9 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
|
|||
case BIO_CTRL_FLUSH:
|
||||
ret = 1;
|
||||
break;
|
||||
case BIO_CTRL_EOF:
|
||||
ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue