Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkcs15-init: Check return value of fseek #3180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/tools/pkcs15-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2504,11 +2504,16 @@ static size_t determine_filesize(const char *filename)
{
FILE *fp;
long ll;
int rc;

if ((fp = fopen(filename,"rb")) == NULL)
fp = fopen(filename,"rb");
if (fp == NULL)
util_fatal("Unable to open %s: %m", filename);

fseek(fp,0L,SEEK_END);
rc = fseek(fp, 0L, SEEK_END);
if (rc != 0)
util_fatal("Unable seek in the opened file %s", filename);

ll = ftell(fp);
if (ll == -1l)
util_fatal("fseek/ftell error");
Expand Down