Skip to contentSkip to conversation

pem: Write encrypted flag in load_container with .crt format

PATCH Applied Andrew Zaborowski 2 participants 2 messages Mar 10, 2021 – Mar 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pem: Write encrypted flag in load_container with .crt format

Make sure a value is written to *out_encrypted whenever l_cert_load_container_file() returns success. Specifically we were forgetting to do this with raw DER-encoded certificates. Fixes the following valgrind warning (sometimes test failure) in test-pem:

==1142== Conditional jump or move depends on uninitialised value(s)

==1142==    at 0x10B427: test_load_file (test-pem.c:369)
==1142==    by 0x10CF53: l_test_run (test.c:83)
==1142==    by 0x10BC19: main (test-pem.c:523)
==1142==
test-pem: unit/test-pem.c:369: test_load_file: Assertion `encrypted == params->expect_encrypted' failed.
---
 ell/cert.c | 3 +++
 1 file changed, 3 insertions(+)
ell/cert.c +3 -0
index 8463a1d..c489f60 100644
@@ -1413,6 +1413,9 @@ static int cert_try_load_der_format(const uint8_t *content, size_t content_len,
 			if (out_privkey)
 				*out_privkey = NULL;
 
+			if (out_encrypted)
+				*out_encrypted = false;
+
 			return 0;
 		}
 
Signature · 1 line
2.27.0
#1 lore raw

Hi Andrew,

Quoted 6 lines · Andrew Zaborowski

Make sure a value is written to *out_encrypted whenever l_cert_load_container_file() returns success. Specifically we were forgetting to do this with raw DER-encoded certificates. Fixes the following valgrind warning (sometimes test failure) in test-pem:

==1142== Conditional jump or move depends on uninitialised value(s)

Quoted 9 lines
==1142==    at 0x10B427: test_load_file (test-pem.c:369)
==1142==    by 0x10CF53: l_test_run (test.c:83)
==1142==    by 0x10BC19: main (test-pem.c:523)
==1142==
test-pem: unit/test-pem.c:369: test_load_file: Assertion `encrypted == params->expect_encrypted' failed.
---
  ell/cert.c | 3 +++
  1 file changed, 3 insertions(+)

Applied, thanks.

Regards,
-Denis