0
0
mirror of https://github.com/OpenVPN/openvpn.git synced 2024-09-19 19:42:30 +02:00

test_pkcs11.c: set file offset to 0 after ftruncate

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.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20240812232158.3776869-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29010.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
Selva Nair 2024-08-12 19:21:58 -04:00 committed by Gert Doering
parent 418463ad27
commit dcf735009c

View File

@ -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++;
}