From 31e9a7a7162fd0b640e64237f5d19fd9e00eb2b4 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Tue, 22 May 2012 09:10:10 +0000 Subject: lemon bug: checking lines is not enough, we have to be sure we're at the end of file to make sure the include file hasn't been altered. problem reported by landry@, deraadt@ --- lib/libsqlite3/tool/lemon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/libsqlite3') diff --git a/lib/libsqlite3/tool/lemon.c b/lib/libsqlite3/tool/lemon.c index c3e612b068e..0b41bdc44b7 100644 --- a/lib/libsqlite3/tool/lemon.c +++ b/lib/libsqlite3/tool/lemon.c @@ -1546,7 +1546,7 @@ int main(int argc, char **argv) /* ** Return a pointer to the next structure in the linked list. */ -#define NEXT(A) (*(char**)(((unsigned long)A)+offset)) +#define NEXT(A) (*(char**)(((char*)A)+offset)) /* ** Inputs: @@ -4025,8 +4025,9 @@ void ReportHeader(struct lemon *lemp) sprintf(pattern,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); if( strcmp(line,pattern) ) break; } + int eof = fgetc(in); fclose(in); - if( i==lemp->nterminal ){ + if( i==lemp->nterminal && eof == EOF ){ /* No change in the file. Don't rewrite it. */ return; } -- cgit v1.2.3