bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Infinite recursion with fopen


From: Bruno Haible
Subject: Re: Infinite recursion with fopen
Date: Tue, 30 Aug 2011 09:58:50 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Michael Goffioul wrote:
> Yes, it fixes the problem, thanks. Note that a similar problem may occur
> in open.c

Thanks for testing. I've applied this patch:


2011-08-30  Bruno Haible  <address@hidden>

        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 <address@hidden>.

--- lib/fopen.c.orig    Tue Aug 30 09:54:22 2011
+++ lib/fopen.c Tue Aug 30 09:52:52 2011
@@ -16,10 +16,13 @@
 
 /* Written by Bruno Haible <address@hidden>, 2007.  */
 
+/* If the user's config.h happens to include <stdio.h>, let it include only
+   the system's <stdio.h> here, so that orig_fopen doesn't recurse to
+   rpl_fopen.  */
+#define __need_FILE
 #include <config.h>
 
 /* Get the original definition of fopen.  It might be defined as a macro.  */
-#define __need_FILE
 #include <stdio.h>
 #undef __need_FILE
 
--- lib/freopen.c.orig  Tue Aug 30 09:54:22 2011
+++ lib/freopen.c       Tue Aug 30 09:52:52 2011
@@ -16,10 +16,13 @@
 
 /* Written by Bruno Haible <address@hidden>, 2007.  */
 
+/* If the user's config.h happens to include <stdio.h>, let it include only
+   the system's <stdio.h> here, so that orig_freopen doesn't recurse to
+   rpl_freopen.  */
+#define __need_FILE
 #include <config.h>
 
 /* Get the original definition of freopen.  It might be defined as a macro.  */
-#define __need_FILE
 #include <stdio.h>
 #undef __need_FILE
 
--- lib/lstat.c.orig    Tue Aug 30 09:54:22 2011
+++ lib/lstat.c Tue Aug 30 09:52:52 2011
@@ -17,6 +17,10 @@
 
 /* written by Jim Meyering */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_lstat doesn't recurse to
+   rpl_lstat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 #if !HAVE_LSTAT
@@ -27,7 +31,6 @@
 #else /* HAVE_LSTAT */
 
 /* Get the original definition of lstat.  It might be defined as a macro.  */
-# define __need_system_sys_stat_h
 # include <sys/types.h>
 # include <sys/stat.h>
 # undef __need_system_sys_stat_h
--- lib/open.c.orig     Tue Aug 30 09:54:22 2011
+++ lib/open.c  Tue Aug 30 09:53:39 2011
@@ -16,13 +16,16 @@
 
 /* Written by Bruno Haible <address@hidden>, 2007.  */
 
+/* If the user's config.h happens to include <fcntl.h>, let it include only
+   the system's <fcntl.h> here, so that orig_open doesn't recurse to
+   rpl_open.  */
+#define __need_system_fcntl_h
 #include <config.h>
 
 /* Get the original definition of open.  It might be defined as a macro.  */
-#define __need_system_fcntl_h
 #include <fcntl.h>
-#undef __need_system_fcntl_h
 #include <sys/types.h>
+#undef __need_system_fcntl_h
 
 static inline int
 orig_open (const char *filename, int flags, mode_t mode)
--- lib/stat.c.orig     Tue Aug 30 09:54:23 2011
+++ lib/stat.c  Tue Aug 30 09:52:52 2011
@@ -16,10 +16,13 @@
 
 /* written by Eric Blake */
 
+/* If the user's config.h happens to include <sys/stat.h>, let it include only
+   the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
+   rpl_stat.  */
+#define __need_system_sys_stat_h
 #include <config.h>
 
 /* Get the original definition of stat.  It might be defined as a macro.  */
-#define __need_system_sys_stat_h
 #include <sys/types.h>
 #include <sys/stat.h>
 #undef __need_system_sys_stat_h
-- 
In memoriam Eberhard Finckh <http://en.wikipedia.org/wiki/Eberhard_Finckh>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]