return -1;
}
- uint16_t version = *input << 8 | *(input + 1);
+ uint16_t version = (uint16_t)(*input << 8) | *(input + 1);
ssl_state->curr_connp->version = version;
/* TLSv1.3 draft1 to draft21 use the version field as earlier TLS
if (ssl_state->current_flags & SSL_AL_FLAG_STATE_SERVER_HELLO) {
cipher_suites_length = 2;
} else if (ssl_state->current_flags & SSL_AL_FLAG_STATE_CLIENT_HELLO) {
- cipher_suites_length = *input << 8 | *(input + 1);
+ cipher_suites_length = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
} else {
return -1;
goto invalid_length;
}
- uint16_t cipher_suite = *input << 8 | *(input + 1);
+ uint16_t cipher_suite = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (TLSDecodeValueIsGREASE(cipher_suite) != 1) {
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t sni_len = *input << 8 | *(input + 1);
+ uint16_t sni_len = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
/* host_name contains the fully qualified domain name,
goto invalid_length;
/* Use the first (and prefered) version as client version */
- ssl_state->curr_connp->version = *input << 8 | *(input + 1);
+ ssl_state->curr_connp->version = (uint16_t)(*input << 8) | *(input + 1);
/* Set a flag to indicate that we have seen this extension */
ssl_state->flags |= SSL_AL_FLAG_CH_VERSION_EXTENSION;
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t ver = *input << 8 | *(input + 1);
+ uint16_t ver = (uint16_t)(*input << 8) | *(input + 1);
if ((ssl_state->flags & SSL_AL_FLAG_CH_VERSION_EXTENSION) &&
(ver > TLS_VERSION_12)) {
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t elliptic_curves_len = *input << 8 | *(input + 1);
+ uint16_t elliptic_curves_len = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (!(HAS_SPACE(elliptic_curves_len)))
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t elliptic_curve = *input << 8 | *(input + 1);
+ uint16_t elliptic_curve = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (TLSDecodeValueIsGREASE(elliptic_curve) != 1) {
if (!(HAS_SPACE(2)))
goto end;
- uint16_t extensions_len = *input << 8 | *(input + 1);
+ uint16_t extensions_len = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (!(HAS_SPACE(extensions_len)))
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t ext_type = *input << 8 | *(input + 1);
+ uint16_t ext_type = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (!(HAS_SPACE(2)))
goto invalid_length;
- uint16_t ext_len = *input << 8 | *(input + 1);
+ uint16_t ext_len = (uint16_t)(*input << 8) | *(input + 1);
input += 2;
if (!(HAS_SPACE(ext_len)))
{
uint8_t hb_type;
uint16_t payload_len;
- uint16_t padding_len;
+ uint32_t padding_len;
/* expect at least 3 bytes: heartbeat type (1) + length (2) */
if (input_len < 3) {
return (ssl_state->curr_connp->record_length - 3);
}
- payload_len = (*input++) << 8;
- payload_len |= (*input++);
+ payload_len = (uint16_t)(*input << 8) | *(input + 1);
/* check that the requested payload length is really present in
the record (CVE-2014-0160) */
if (input_len >= 5) {
ssl_state->curr_connp->content_type = input[0];
if (!skip_version) {
- ssl_state->curr_connp->version = input[1] << 8;
- ssl_state->curr_connp->version |= input[2];
+ ssl_state->curr_connp->version = (uint16_t)(input[1] << 8) | input[2];
}
ssl_state->curr_connp->record_length = input[3] << 8;
ssl_state->curr_connp->record_length |= input[4];
/* fall through */
case 1:
if (!skip_version) {
- ssl_state->curr_connp->version = *(input++) << 8;
+ ssl_state->curr_connp->version = (uint16_t)(*(input++) << 8);
} else {
input++;
}
switch (ssl_state->curr_connp->bytes_processed) {
case 4:
if (input_len >= 6) {
- uint16_t session_id_length = input[5] | (input[4] << 8);
+ uint16_t session_id_length = (input[5]) | (uint16_t)(input[4] << 8);
input += 6;
input_len -= 6;
ssl_state->curr_connp->bytes_processed += 6;
switch (ssl_state->curr_connp->bytes_processed) {
case 3:
if (input_len >= 6) {
- uint16_t session_id_length = input[5] | (input[4] << 8);
+ uint16_t session_id_length = (input[5]) | (uint16_t)(input[4] << 8);
input += 6;
input_len -= 6;
ssl_state->curr_connp->bytes_processed += 6;