@@ -193,6 +193,7 @@ static int parser_auth(struct table *t, const char *filename)
regmatch_t match[4];
char buf[1024];
size_t end;
+ long pos;
int len;
int done = 0;
int r;
@@ -228,12 +229,12 @@ static int parser_auth(struct table *t, const char *filename)
last_reg = strtol(last_reg_s, NULL, 16);
do {
- if (fgets(buf, 1024, file) == NULL) {
+ if ((fgets(buf, 1024, file) == NULL) || (pos = ftell(file)) < 0) {
fclose(file);
return -1;
}
len = strlen(buf);
- if (ftell(file) == end)
+ if (pos == end)
done = 1;
if (len) {
r = regexec(&mask_rex, buf, 4, match, 0);