From 8c5ef4293511ccf4326f3d30741a5134e06a3fc3 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 7 Oct 2014 07:33:28 +0200 Subject: [PATCH] bin/xbps-checkvers/main.c: CID 62705 (argument cannot be negative) --- bin/xbps-checkvers/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/xbps-checkvers/main.c b/bin/xbps-checkvers/main.c index 4818c1fc..04ef8a0c 100644 --- a/bin/xbps-checkvers/main.c +++ b/bin/xbps-checkvers/main.c @@ -245,6 +245,7 @@ static bool rcv_load_file(rcv_t *rcv, const char *fname) { FILE *file; + long offset; rcv->fname = fname; 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); - rcv->len = (size_t)ftell(file); + offset = ftell(file); fseek(file, 0, SEEK_SET); + if (offset == -1) { + fclose(file); + return false; + } + rcv->len = (size_t)offset; + if (rcv->input != NULL) free(rcv->input);