From 8ff829dbcdf1ba4fa084f64e4716a6ac1f039b85 Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Thu, 29 Dec 2022 18:13:57 +0800 Subject: [PATCH] Fix a typical error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When call `foo(type *ret)`,always use `type` to receive the return value. --- src/tls13.c | 5 +++-- src/tls_trace.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tls13.c b/src/tls13.c index 1e8a45a5..390fd7fb 100644 --- a/src/tls13.c +++ b/src/tls13.c @@ -855,6 +855,7 @@ int tls13_record_get_handshake_certificate_verify(const uint8_t *record, int type; const uint8_t *p; size_t len ; + uint16_t alg; if (tls_record_get_handshake(record, &type, &p, &len) != 1 || type != TLS_handshake_certificate_verify) { @@ -862,9 +863,9 @@ int tls13_record_get_handshake_certificate_verify(const uint8_t *record, return -1; } - *sign_algor = 0; - tls_uint16_from_bytes((uint16_t *)sign_algor, &p, &len); + tls_uint16_from_bytes(&alg, &p, &len); tls_uint16array_from_bytes(sig, siglen, &p, &len); + *sign_algor = alg; return 1; } diff --git a/src/tls_trace.c b/src/tls_trace.c index cc653362..c0012cc2 100644 --- a/src/tls_trace.c +++ b/src/tls_trace.c @@ -540,7 +540,7 @@ int tls_client_hello_print(FILE *fp, const uint8_t *data, size_t datalen, int fo size_t i; format_print(fp, format, indent, "ClientHello\n"); indent += 4; - if (tls_uint16_from_bytes((uint16_t *)&protocol, &data, &datalen) != 1) goto end; + if (tls_uint16_from_bytes(&protocol, &data, &datalen) != 1) goto end; format_print(fp, format, indent, "Version: %s (%d.%d)\n", tls_protocol_name(protocol), protocol >> 8, protocol & 0xff); if (tls_array_from_bytes(&random, 32, &data, &datalen) != 1) goto end; @@ -892,7 +892,7 @@ int tls_handshake_print(FILE *fp, const uint8_t *handshake, size_t handshakelen, const uint8_t *cp = handshake; uint8_t type; const uint8_t *data; - size_t datalen = 0; + uint24_t datalen; format_print(fp, format, indent, "Handshake\n"); indent += 4; @@ -902,7 +902,7 @@ int tls_handshake_print(FILE *fp, const uint8_t *handshake, size_t handshakelen, return -1; } format_print(fp, format, indent, "Type: %s (%d)\n", tls_handshake_type_name(type), type); - if (tls_uint24_from_bytes((uint24_t *)&datalen, &cp, &handshakelen) != 1) { + if (tls_uint24_from_bytes(&datalen, &cp, &handshakelen) != 1) { error_print(); return -1; }