Skip to content

Commit

Permalink
[nrf fromlist] bugfix
Browse files Browse the repository at this point in the history
Upstream PR: Mbed-TLS/mbedtls#5061

Jira: NCSDK-16493

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
  • Loading branch information
Hannes Tschofenig authored and plskeggs committed Sep 12, 2022
1 parent cfc8330 commit 059740e
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions library/ssl_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,30 +540,33 @@ static void ssl_extract_add_data_from_record( unsigned char* add_data,
((void) minor_ver);

#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
if( rec->cid_len != 0 )
if( rec->cid_len == 0 )
{
// seq_num_placeholder
memcpy( cur, seq_num_placeholder, sizeof(seq_num_placeholder) );
cur += sizeof( seq_num_placeholder );

// tls12_cid type
*cur = rec->type;
cur++;

// cid_length
*cur = rec->cid_len;
cur++;
}
else
{
// epoch + sequence number
memcpy( cur, rec->ctr, sizeof( rec->ctr ) );
cur += sizeof( rec->ctr );
} else
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
{
memcpy(cur, rec->ctr, sizeof(rec->ctr));
cur += sizeof(rec->ctr);
}
#else
// epoch + sequence number
memcpy(cur, rec->ctr, sizeof(rec->ctr));
cur += sizeof(rec->ctr);
}

#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
if( rec->cid_len != 0 )
{
// seq_num_placeholder
memcpy( cur, seq_num_placeholder, sizeof(seq_num_placeholder) );
cur += sizeof( seq_num_placeholder );

// tls12_cid type
*cur = rec->type;
cur++;

// cid_length
*cur = rec->cid_len;
cur++;

#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
}

Expand Down

0 comments on commit 059740e

Please sign in to comment.