tls: fix order of operations to copy peer certificate

The memcpy is done before assigning the length, so the length is not
set and is therefore either 0 (so no peer certificate will be available)
or a random number (that can lead to crashes) making the feature not work.

The MR simply copies first the length that will make the memcpy work.
v1.6_develop_rgoose_sntp
Federico Pellegrin 3 years ago committed by Michael Zillgith
parent d427179250
commit 4b06fd3b6e

@ -189,8 +189,8 @@ verifyCertificate (void* parameter, mbedtls_x509_crt *crt, int certificate_depth
self->peerCert = (uint8_t*) GLOBAL_MALLOC(crt->raw.len); self->peerCert = (uint8_t*) GLOBAL_MALLOC(crt->raw.len);
if (self->peerCert) { if (self->peerCert) {
memcpy(self->peerCert, crt->raw.p, self->peerCertLength);
self->peerCertLength = (int)crt->raw.len; self->peerCertLength = (int)crt->raw.len;
memcpy(self->peerCert, crt->raw.p, self->peerCertLength);
} }
} }

Loading…
Cancel
Save