bin/xbps-checkvers/main.c: CID 62705 (argument cannot be negative)

This commit is contained in:
Juan RP 2014-10-07 07:33:28 +02:00
parent 1a19adf85c
commit 8c5ef42935

View File

@ -245,6 +245,7 @@ static bool
rcv_load_file(rcv_t *rcv, const char *fname) rcv_load_file(rcv_t *rcv, const char *fname)
{ {
FILE *file; FILE *file;
long offset;
rcv->fname = fname; rcv->fname = fname;
if ((file = fopen(rcv->fname, "r")) == NULL) { if ((file = fopen(rcv->fname, "r")) == NULL) {
@ -256,9 +257,15 @@ rcv_load_file(rcv_t *rcv, const char *fname)
} }
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
rcv->len = (size_t)ftell(file); offset = ftell(file);
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
if (offset == -1) {
fclose(file);
return false;
}
rcv->len = (size_t)offset;
if (rcv->input != NULL) if (rcv->input != NULL)
free(rcv->input); free(rcv->input);