提交 aebe9e39 编写于 作者: B Benjamin Kaduk

Fix some -Wshadow warnings

Found using various (old-ish) versions of gcc.
Reviewed-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2940)
上级 d8f9213a
...@@ -743,7 +743,7 @@ int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr) ...@@ -743,7 +743,7 @@ int ssl3_do_compress(SSL *ssl, SSL3_RECORD *wr)
* -1: if the record's padding is invalid or, if sending, an internal error * -1: if the record's padding is invalid or, if sending, an internal error
* occurred. * occurred.
*/ */
int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int sending)
{ {
SSL3_RECORD *rec; SSL3_RECORD *rec;
EVP_CIPHER_CTX *ds; EVP_CIPHER_CTX *ds;
...@@ -758,7 +758,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) ...@@ -758,7 +758,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send)
*/ */
if (n_recs != 1) if (n_recs != 1)
return 0; return 0;
if (send) { if (sending) {
ds = s->enc_write_ctx; ds = s->enc_write_ctx;
if (s->enc_write_ctx == NULL) if (s->enc_write_ctx == NULL)
enc = NULL; enc = NULL;
...@@ -782,7 +782,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) ...@@ -782,7 +782,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send)
/* COMPRESS */ /* COMPRESS */
if ((bs != 1) && send) { if ((bs != 1) && sending) {
i = bs - (l % bs); i = bs - (l % bs);
/* we need to add 'i-1' padding bytes */ /* we need to add 'i-1' padding bytes */
...@@ -796,7 +796,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) ...@@ -796,7 +796,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send)
rec->input[l - 1] = (unsigned char)(i - 1); rec->input[l - 1] = (unsigned char)(i - 1);
} }
if (!send) { if (!sending) {
if (l == 0 || l % bs != 0) if (l == 0 || l % bs != 0)
return 0; return 0;
/* otherwise, rec->length >= bs */ /* otherwise, rec->length >= bs */
...@@ -813,7 +813,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) ...@@ -813,7 +813,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send)
return -1; return -1;
mac_size = (size_t)imac_size; mac_size = (size_t)imac_size;
} }
if ((bs != 1) && !send) if ((bs != 1) && !sending)
return ssl3_cbc_remove_padding(rec, bs, mac_size); return ssl3_cbc_remove_padding(rec, bs, mac_size);
} }
return (1); return (1);
...@@ -830,7 +830,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send) ...@@ -830,7 +830,7 @@ int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send)
* -1: if the record's padding/AEAD-authenticator is invalid or, if sending, * -1: if the record's padding/AEAD-authenticator is invalid or, if sending,
* an internal error occurred. * an internal error occurred.
*/ */
int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int sending)
{ {
EVP_CIPHER_CTX *ds; EVP_CIPHER_CTX *ds;
size_t reclen[SSL_MAX_PIPELINES]; size_t reclen[SSL_MAX_PIPELINES];
...@@ -844,7 +844,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -844,7 +844,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
if (n_recs == 0) if (n_recs == 0)
return 0; return 0;
if (send) { if (sending) {
if (EVP_MD_CTX_md(s->write_hash)) { if (EVP_MD_CTX_md(s->write_hash)) {
int n = EVP_MD_CTX_size(s->write_hash); int n = EVP_MD_CTX_size(s->write_hash);
OPENSSL_assert(n >= 0); OPENSSL_assert(n >= 0);
...@@ -916,14 +916,14 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -916,14 +916,14 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
& EVP_CIPH_FLAG_AEAD_CIPHER) { & EVP_CIPH_FLAG_AEAD_CIPHER) {
unsigned char *seq; unsigned char *seq;
seq = send ? RECORD_LAYER_get_write_sequence(&s->rlayer) seq = sending ? RECORD_LAYER_get_write_sequence(&s->rlayer)
: RECORD_LAYER_get_read_sequence(&s->rlayer); : RECORD_LAYER_get_read_sequence(&s->rlayer);
if (SSL_IS_DTLS(s)) { if (SSL_IS_DTLS(s)) {
/* DTLS does not support pipelining */ /* DTLS does not support pipelining */
unsigned char dtlsseq[9], *p = dtlsseq; unsigned char dtlsseq[9], *p = dtlsseq;
s2n(send ? DTLS_RECORD_LAYER_get_w_epoch(&s->rlayer) : s2n(sending ? DTLS_RECORD_LAYER_get_w_epoch(&s->rlayer) :
DTLS_RECORD_LAYER_get_r_epoch(&s->rlayer), p); DTLS_RECORD_LAYER_get_r_epoch(&s->rlayer), p);
memcpy(p, &seq[2], 6); memcpy(p, &seq[2], 6);
memcpy(buf[ctr], dtlsseq, 8); memcpy(buf[ctr], dtlsseq, 8);
...@@ -946,12 +946,12 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -946,12 +946,12 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
if (pad <= 0) if (pad <= 0)
return -1; return -1;
if (send) { if (sending) {
reclen[ctr] += pad; reclen[ctr] += pad;
recs[ctr].length += pad; recs[ctr].length += pad;
} }
} else if ((bs != 1) && send) { } else if ((bs != 1) && sending) {
padnum = bs - (reclen[ctr] % bs); padnum = bs - (reclen[ctr] % bs);
/* Add weird padding of upto 256 bytes */ /* Add weird padding of upto 256 bytes */
...@@ -966,7 +966,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -966,7 +966,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
recs[ctr].length += padnum; recs[ctr].length += padnum;
} }
if (!send) { if (!sending) {
if (reclen[ctr] == 0 || reclen[ctr] % bs != 0) if (reclen[ctr] == 0 || reclen[ctr] % bs != 0)
return 0; return 0;
} }
...@@ -1003,7 +1003,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -1003,7 +1003,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
? (tmpr < 0) ? (tmpr < 0)
: (tmpr == 0)) : (tmpr == 0))
return -1; /* AEAD can fail to verify MAC */ return -1; /* AEAD can fail to verify MAC */
if (send == 0) { if (sending == 0) {
if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE) { if (EVP_CIPHER_mode(enc) == EVP_CIPH_GCM_MODE) {
for (ctr = 0; ctr < n_recs; ctr++) { for (ctr = 0; ctr < n_recs; ctr++) {
recs[ctr].data += EVP_GCM_TLS_EXPLICIT_IV_LEN; recs[ctr].data += EVP_GCM_TLS_EXPLICIT_IV_LEN;
...@@ -1026,7 +1026,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -1026,7 +1026,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
return -1; return -1;
mac_size = (size_t)imac_size; mac_size = (size_t)imac_size;
} }
if ((bs != 1) && !send) { if ((bs != 1) && !sending) {
int tmpret; int tmpret;
for (ctr = 0; ctr < n_recs; ctr++) { for (ctr = 0; ctr < n_recs; ctr++) {
tmpret = tls1_cbc_remove_padding(s, &recs[ctr], bs, mac_size); tmpret = tls1_cbc_remove_padding(s, &recs[ctr], bs, mac_size);
...@@ -1041,7 +1041,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -1041,7 +1041,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
ret, -1); ret, -1);
} }
} }
if (pad && !send) { if (pad && !sending) {
for (ctr = 0; ctr < n_recs; ctr++) { for (ctr = 0; ctr < n_recs; ctr++) {
recs[ctr].length -= pad; recs[ctr].length -= pad;
} }
...@@ -1050,7 +1050,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send) ...@@ -1050,7 +1050,7 @@ int tls1_enc(SSL *s, SSL3_RECORD *recs, size_t n_recs, int send)
return ret; return ret;
} }
int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int sending)
{ {
unsigned char *mac_sec, *seq; unsigned char *mac_sec, *seq;
const EVP_MD_CTX *hash; const EVP_MD_CTX *hash;
...@@ -1059,7 +1059,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1059,7 +1059,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
size_t npad; size_t npad;
int t; int t;
if (send) { if (sending) {
mac_sec = &(ssl->s3->write_mac_secret[0]); mac_sec = &(ssl->s3->write_mac_secret[0]);
seq = RECORD_LAYER_get_write_sequence(&ssl->rlayer); seq = RECORD_LAYER_get_write_sequence(&ssl->rlayer);
hash = ssl->write_hash; hash = ssl->write_hash;
...@@ -1075,7 +1075,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1075,7 +1075,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
md_size = t; md_size = t;
npad = (48 / md_size) * md_size; npad = (48 / md_size) * md_size;
if (!send && if (!sending &&
EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE && EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
ssl3_cbc_record_digest_supported(hash)) { ssl3_cbc_record_digest_supported(hash)) {
/* /*
...@@ -1146,7 +1146,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1146,7 +1146,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
return 1; return 1;
} }
int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int sending)
{ {
unsigned char *seq; unsigned char *seq;
EVP_MD_CTX *hash; EVP_MD_CTX *hash;
...@@ -1154,11 +1154,11 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1154,11 +1154,11 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
int i; int i;
EVP_MD_CTX *hmac = NULL, *mac_ctx; EVP_MD_CTX *hmac = NULL, *mac_ctx;
unsigned char header[13]; unsigned char header[13];
int stream_mac = (send ? (ssl->mac_flags & SSL_MAC_FLAG_WRITE_MAC_STREAM) int stream_mac = (sending ? (ssl->mac_flags & SSL_MAC_FLAG_WRITE_MAC_STREAM)
: (ssl->mac_flags & SSL_MAC_FLAG_READ_MAC_STREAM)); : (ssl->mac_flags & SSL_MAC_FLAG_READ_MAC_STREAM));
int t; int t;
if (send) { if (sending) {
seq = RECORD_LAYER_get_write_sequence(&ssl->rlayer); seq = RECORD_LAYER_get_write_sequence(&ssl->rlayer);
hash = ssl->write_hash; hash = ssl->write_hash;
} else { } else {
...@@ -1183,7 +1183,7 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1183,7 +1183,7 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
if (SSL_IS_DTLS(ssl)) { if (SSL_IS_DTLS(ssl)) {
unsigned char dtlsseq[8], *p = dtlsseq; unsigned char dtlsseq[8], *p = dtlsseq;
s2n(send ? DTLS_RECORD_LAYER_get_w_epoch(&ssl->rlayer) : s2n(sending ? DTLS_RECORD_LAYER_get_w_epoch(&ssl->rlayer) :
DTLS_RECORD_LAYER_get_r_epoch(&ssl->rlayer), p); DTLS_RECORD_LAYER_get_r_epoch(&ssl->rlayer), p);
memcpy(p, &seq[2], 6); memcpy(p, &seq[2], 6);
...@@ -1197,7 +1197,7 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send) ...@@ -1197,7 +1197,7 @@ int tls1_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send)
header[11] = (unsigned char)(rec->length >> 8); header[11] = (unsigned char)(rec->length >> 8);
header[12] = (unsigned char)(rec->length & 0xff); header[12] = (unsigned char)(rec->length & 0xff);
if (!send && !SSL_READ_ETM(ssl) && if (!sending && !SSL_READ_ETM(ssl) &&
EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE && EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE &&
ssl3_cbc_record_digest_supported(mac_ctx)) { ssl3_cbc_record_digest_supported(mac_ctx)) {
/* /*
......
...@@ -317,7 +317,7 @@ static int allws(const char *cp) ...@@ -317,7 +317,7 @@ static int allws(const char *cp)
return 1; return 1;
} }
static int test_tlsafile(SSL_CTX *ctx, const char *basename, static int test_tlsafile(SSL_CTX *ctx, const char *base_name,
BIO *f, const char *path) BIO *f, const char *path)
{ {
char *line; char *line;
...@@ -353,7 +353,7 @@ static int test_tlsafile(SSL_CTX *ctx, const char *basename, ...@@ -353,7 +353,7 @@ static int test_tlsafile(SSL_CTX *ctx, const char *basename,
if ((ssl = SSL_new(ctx)) == NULL) if ((ssl = SSL_new(ctx)) == NULL)
return -1; return -1;
SSL_set_connect_state(ssl); SSL_set_connect_state(ssl);
if (SSL_dane_enable(ssl, basename) <= 0) { if (SSL_dane_enable(ssl, base_name) <= 0) {
SSL_free(ssl); SSL_free(ssl);
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册