mirror of https://github.com/wolfSSL/wolfTPM.git
F-13458 - Stop the extend hashing loop on a short or failed read
parent
18691a8b20
commit
e7a00928bd
|
|
@ -162,11 +162,19 @@ int TPM2_PCR_Extend_Test(void* userCtx, int argc, char *argv[])
|
|||
rc = wc_HashInit(&dig, hashType);
|
||||
if (rc == 0)
|
||||
hashInitialized = 1;
|
||||
while (rc == 0 && !XFEOF(fp)) {
|
||||
while (rc == 0) {
|
||||
len = XFREAD(dataBuffer, 1, sizeof(dataBuffer), fp);
|
||||
if (len > 0) {
|
||||
rc = wc_HashUpdate(&dig, hashType, dataBuffer, (int)len);
|
||||
}
|
||||
if (len < sizeof(dataBuffer)) {
|
||||
/* Short read: end of file, or an input error to report */
|
||||
if (!XFEOF(fp)) {
|
||||
printf("Error reading file %s\n", filename);
|
||||
rc = BAD_FUNC_ARG;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
XFCLOSE(fp);
|
||||
if (rc == 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue