You need to sign in or sign up before continuing.
提交 6b8f5d0d 编写于 作者: M Matt Caswell

Change the new functions to use size_t

Change the new SSL_get_client_random(), SSL_get_server_random() and
SSL_SESSION_get_master_key() functions to use size_t for |outlen| instead of
int.
Reviewed-by: NTim Hudson <tjh@openssl.org>
上级 7470cefc
...@@ -8,9 +8,9 @@ SSL_get_client_random, SSL_get_server_random, SSL_SESSION_get_master_key - retri ...@@ -8,9 +8,9 @@ SSL_get_client_random, SSL_get_server_random, SSL_SESSION_get_master_key - retri
#include <openssl/ssl.h> #include <openssl/ssl.h>
int SSL_get_client_random(const SSL *ssl, unsigned char *out, int outlen); int SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen);
int SSL_get_server_random(const SSL *ssl, unsigned char *out, int outlen); int SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen);
int SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, int outlen); int SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
=head1 DESCRIPTION =head1 DESCRIPTION
......
...@@ -1652,9 +1652,12 @@ void SSL_set_state(SSL *ssl, int state); ...@@ -1652,9 +1652,12 @@ void SSL_set_state(SSL *ssl, int state);
void SSL_set_verify_result(SSL *ssl, long v); void SSL_set_verify_result(SSL *ssl, long v);
__owur long SSL_get_verify_result(const SSL *ssl); __owur long SSL_get_verify_result(const SSL *ssl);
__owur int SSL_get_client_random(const SSL *ssl, unsigned char *out, int outlen); __owur int SSL_get_client_random(const SSL *ssl, unsigned char *out,
__owur int SSL_get_server_random(const SSL *ssl, unsigned char *out, int outlen); size_t outlen);
__owur int SSL_SESSION_get_master_key(const SSL_SESSION *ssl, unsigned char *out, int outlen); __owur int SSL_get_server_random(const SSL *ssl, unsigned char *out,
size_t outlen);
__owur int SSL_SESSION_get_master_key(const SSL_SESSION *ssl,
unsigned char *out, size_t outlen);
__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data); __owur int SSL_set_ex_data(SSL *ssl, int idx, void *data);
void *SSL_get_ex_data(const SSL *ssl, int idx); void *SSL_get_ex_data(const SSL *ssl, int idx);
......
...@@ -2897,9 +2897,9 @@ long SSL_get_verify_result(const SSL *ssl) ...@@ -2897,9 +2897,9 @@ long SSL_get_verify_result(const SSL *ssl)
return (ssl->verify_result); return (ssl->verify_result);
} }
int SSL_get_client_random(const SSL *ssl, unsigned char *out, int outlen) int SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen)
{ {
if (outlen < 0) if (outlen == 0)
return sizeof(ssl->s3->client_random); return sizeof(ssl->s3->client_random);
if (outlen > sizeof(ssl->s3->client_random)) if (outlen > sizeof(ssl->s3->client_random))
outlen = sizeof(ssl->s3->client_random); outlen = sizeof(ssl->s3->client_random);
...@@ -2907,9 +2907,9 @@ int SSL_get_client_random(const SSL *ssl, unsigned char *out, int outlen) ...@@ -2907,9 +2907,9 @@ int SSL_get_client_random(const SSL *ssl, unsigned char *out, int outlen)
return (outlen); return (outlen);
} }
int SSL_get_server_random(const SSL *ssl, unsigned char *out, int outlen) int SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen)
{ {
if (outlen < 0) if (outlen == 0)
return sizeof(ssl->s3->server_random); return sizeof(ssl->s3->server_random);
if (outlen > sizeof(ssl->s3->server_random)) if (outlen > sizeof(ssl->s3->server_random))
outlen = sizeof(ssl->s3->server_random); outlen = sizeof(ssl->s3->server_random);
...@@ -2918,11 +2918,15 @@ int SSL_get_server_random(const SSL *ssl, unsigned char *out, int outlen) ...@@ -2918,11 +2918,15 @@ int SSL_get_server_random(const SSL *ssl, unsigned char *out, int outlen)
} }
int SSL_SESSION_get_master_key(const SSL_SESSION *session, int SSL_SESSION_get_master_key(const SSL_SESSION *session,
unsigned char *out, int outlen) unsigned char *out, size_t outlen)
{ {
if (outlen < 0) if (outlen == 0)
return session->master_key_length; return session->master_key_length;
if (outlen > session->master_key_length) if (session->master_key_length < 0) {
/* Should never happen */
return 0;
}
if (outlen > (size_t)session->master_key_length)
outlen = session->master_key_length; outlen = session->master_key_length;
memcpy(out, session->master_key, outlen); memcpy(out, session->master_key, outlen);
return (outlen); return (outlen);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册