TT#108003 Do not print the DTLS certificate and private key on OOM

When open_memstream() fails, we should not try to write to it.

Change-Id: I9f92a1e1cc4aebe005039f28e5e3219e323e63c6
Warned-by: coverity
pull/1194/head
Guillem Jover 4 years ago
parent 009aa21bc0
commit 07716a6a85

@ -161,6 +161,10 @@ static void dump_cert(struct dtls_cert *cert) {
/* cert */
fp = open_memstream(&buf, &len);
if (!fp) {
ilogs(crypto, LOG_ERROR, "Failed to allocate memory to dump DTLS certificate");
return;
}
PEM_write_X509(fp, cert->x509);
fclose(fp);
@ -169,6 +173,10 @@ static void dump_cert(struct dtls_cert *cert) {
/* key */
fp = open_memstream(&buf, &len);
if (!fp) {
ilogs(crypto, LOG_ERROR, "Failed to allocate memory to dump DTLS private key");
return;
}
PEM_write_PrivateKey(fp, cert->pkey, NULL, NULL, 0, 0, NULL);
fclose(fp);

Loading…
Cancel
Save