From c29a7464f1218da01129bea72cbfc3dcb524881a Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 30 Aug 2011 09:57:33 +0200 Subject: [PATCH] Avoid endless recursions if config.h includes some header files. * lib/fopen.c (__need_FILE): Define already before including config.h. * lib/freopen.c (__need_FILE): Likewise. * lib/open.c (__need_system_fcntl_h): Likewise. * lib/stat.c (__need_system_sys_stat_h): Likewise. * lib/lstat.c (__need_system_sys_stat_h): Likewise. Reported by Michael Goffioul . --- ChangeLog | 10 ++++++++++ lib/fopen.c | 5 ++++- lib/freopen.c | 5 ++++- lib/lstat.c | 5 ++++- lib/open.c | 7 +++++-- lib/stat.c | 5 ++++- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index aef20cd4a..c7d961e08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-08-30 Bruno Haible + + Avoid endless recursions if config.h includes some header files. + * lib/fopen.c (__need_FILE): Define already before including config.h. + * lib/freopen.c (__need_FILE): Likewise. + * lib/open.c (__need_system_fcntl_h): Likewise. + * lib/stat.c (__need_system_sys_stat_h): Likewise. + * lib/lstat.c (__need_system_sys_stat_h): Likewise. + Reported by Michael Goffioul . + 2011-08-25 Karl Berry * config/srclist.txt (ylwrap): new try. diff --git a/lib/fopen.c b/lib/fopen.c index 81c861724..33412fbce 100644 --- a/lib/fopen.c +++ b/lib/fopen.c @@ -16,10 +16,13 @@ /* Written by Bruno Haible , 2007. */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_fopen doesn't recurse to + rpl_fopen. */ +#define __need_FILE #include /* Get the original definition of fopen. It might be defined as a macro. */ -#define __need_FILE #include #undef __need_FILE diff --git a/lib/freopen.c b/lib/freopen.c index 0decbafc9..c76336580 100644 --- a/lib/freopen.c +++ b/lib/freopen.c @@ -16,10 +16,13 @@ /* Written by Bruno Haible , 2007. */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_freopen doesn't recurse to + rpl_freopen. */ +#define __need_FILE #include /* Get the original definition of freopen. It might be defined as a macro. */ -#define __need_FILE #include #undef __need_FILE diff --git a/lib/lstat.c b/lib/lstat.c index b26065ede..29fc6d25f 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -17,6 +17,10 @@ /* written by Jim Meyering */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_lstat doesn't recurse to + rpl_lstat. */ +#define __need_system_sys_stat_h #include #if !HAVE_LSTAT @@ -27,7 +31,6 @@ typedef int dummy; #else /* HAVE_LSTAT */ /* Get the original definition of lstat. It might be defined as a macro. */ -# define __need_system_sys_stat_h # include # include # undef __need_system_sys_stat_h diff --git a/lib/open.c b/lib/open.c index e60b61994..ffd3b8ded 100644 --- a/lib/open.c +++ b/lib/open.c @@ -16,13 +16,16 @@ /* Written by Bruno Haible , 2007. */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_open doesn't recurse to + rpl_open. */ +#define __need_system_fcntl_h #include /* Get the original definition of open. It might be defined as a macro. */ -#define __need_system_fcntl_h #include -#undef __need_system_fcntl_h #include +#undef __need_system_fcntl_h static inline int orig_open (const char *filename, int flags, mode_t mode) diff --git a/lib/stat.c b/lib/stat.c index f07370dd0..6c354d1d3 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -16,10 +16,13 @@ /* written by Eric Blake */ +/* If the user's config.h happens to include , let it include only + the system's here, so that orig_stat doesn't recurse to + rpl_stat. */ +#define __need_system_sys_stat_h #include /* Get the original definition of stat. It might be defined as a macro. */ -#define __need_system_sys_stat_h #include #include #undef __need_system_sys_stat_h -- 2.11.0