Import OpenSSL 1.0.2p
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -1404,28 +1404,37 @@ int SSL_set_cipher_list(SSL *s, const char *str)
|
||||
}
|
||||
|
||||
/* works well for SSLv2, not so good for SSLv3 */
|
||||
char *SSL_get_shared_ciphers(const SSL *s, char *buf, int len)
|
||||
char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size)
|
||||
{
|
||||
char *p;
|
||||
STACK_OF(SSL_CIPHER) *sk;
|
||||
STACK_OF(SSL_CIPHER) *clntsk, *srvrsk;
|
||||
SSL_CIPHER *c;
|
||||
int i;
|
||||
|
||||
if ((s->session == NULL) || (s->session->ciphers == NULL) || (len < 2))
|
||||
return (NULL);
|
||||
|
||||
p = buf;
|
||||
sk = s->session->ciphers;
|
||||
|
||||
if (sk_SSL_CIPHER_num(sk) == 0)
|
||||
if (!s->server
|
||||
|| s->session == NULL
|
||||
|| s->session->ciphers == NULL
|
||||
|| size < 2)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
|
||||
p = buf;
|
||||
clntsk = s->session->ciphers;
|
||||
srvrsk = SSL_get_ciphers(s);
|
||||
if (clntsk == NULL || srvrsk == NULL)
|
||||
return NULL;
|
||||
|
||||
if (sk_SSL_CIPHER_num(clntsk) == 0 || sk_SSL_CIPHER_num(srvrsk) == 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < sk_SSL_CIPHER_num(clntsk); i++) {
|
||||
int n;
|
||||
|
||||
c = sk_SSL_CIPHER_value(sk, i);
|
||||
c = sk_SSL_CIPHER_value(clntsk, i);
|
||||
if (sk_SSL_CIPHER_find(srvrsk, c) < 0)
|
||||
continue;
|
||||
|
||||
n = strlen(c->name);
|
||||
if (n + 1 > len) {
|
||||
if (n + 1 > size) {
|
||||
if (p != buf)
|
||||
--p;
|
||||
*p = '\0';
|
||||
@@ -1434,7 +1443,7 @@ char *SSL_get_shared_ciphers(const SSL *s, char *buf, int len)
|
||||
strcpy(p, c->name);
|
||||
p += n;
|
||||
*(p++) = ':';
|
||||
len -= n + 1;
|
||||
size -= n + 1;
|
||||
}
|
||||
p[-1] = '\0';
|
||||
return (buf);
|
||||
|
||||
Reference in New Issue
Block a user