fix possible access outside the array.

if 5000 bytes are read, then at the end of the array we will write zero beyond its boundaries, damaging the stack.
Here's a simple solution. if you see the need to increase the array itself, let me know.
This commit is contained in:
ihsinme 2021-05-02 14:42:23 +03:00 committed by Frank Morgner
parent 32004e74ce
commit 50eaa6bf57
1 changed files with 1 additions and 1 deletions

View File

@ -3234,7 +3234,7 @@ static int write_object(CK_SESSION_HANDLE session)
if (opt_attr_from_file) {
if (!(f = fopen(opt_attr_from_file, "rb")))
util_fatal("Couldn't open file \"%s\"", opt_attr_from_file);
certdata_len = fread(certdata, 1, sizeof(certdata), f);
certdata_len = fread(certdata, 1, sizeof(certdata) - 1, f);
fclose(f);
if (certdata_len < 0)
util_fatal("Couldn't read from file \"%s\"", opt_attr_from_file);