From: Selva Nair <selva.n...@gmail.com> Currently key and cert file fd's are reused after ftruncate() without setting the offset to zero. This causes subsequent data to be written at some finite offset with the hole in the file automatically filled by zeros. Fix it by calling lseek() to set the offset to zero.
The test works nevertheless because p11tool seem to generously ignore any junk before the "BEGIN" marker. Change-Id: Ib0fe15a4ba18d89216b0288e6cd6be66ed377bd4 Signed-off-by: Selva Nair <selva.n...@gmail.com> --- tests/unit_tests/openvpn/test_pkcs11.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit_tests/openvpn/test_pkcs11.c b/tests/unit_tests/openvpn/test_pkcs11.c index 5518fa15..3fe3e460 100644 --- a/tests/unit_tests/openvpn/test_pkcs11.c +++ b/tests/unit_tests/openvpn/test_pkcs11.c @@ -273,6 +273,8 @@ init(void **state) assert_int_equal(ftruncate(cert_fd, 0), 0); assert_int_equal(ftruncate(key_fd, 0), 0); + assert_int_equal(lseek(cert_fd, 0, SEEK_SET), 0); + assert_int_equal(lseek(key_fd, 0, SEEK_SET), 0); num_certs++; } -- 2.34.1 _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel