mirror of https://github.com/ericonr/get-otp.git
Add fread checking and fix order of parameters.
Not a problem on little endian machines, potentially a problem on big endian ones. Thanks Riastradh from freenode.##crypto.
This commit is contained in:
parent
4fe7044f17
commit
2075f4b4d2
|
@ -94,7 +94,10 @@ static ssize_t open_file_for_read(char *name, uint8_t **buffer)
|
|||
return -1;
|
||||
}
|
||||
|
||||
fread(*buffer, size, 1, file);
|
||||
if (fread(*buffer, 1, size, file) != (size_t)size) {
|
||||
fputs("mismatched file size and bytes read!\n", stderr);
|
||||
return -1;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
return size;
|
||||
|
|
Loading…
Reference in New Issue