This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fdisk crashes (Was: glibc 2.1.93)


On Tue, Sep 05, 2000 at 09:26:53PM +0200, Martin v. Loewis wrote:
> On my RedHat 5.2 installation, after upgrading numerous utilities and
> recently installing glibc 2.1.93, I now find that fdisk crashes:
> 
> [root@mira martin]# /sbin/fdisk 
> Using /dev/sda as default device!
> The number of cylinders for this disk is set to 1109.
> This is larger than 1024, and may cause problems with:
> 1) software that runs at boot time (e.g., LILO)
> 2) booting and partitioning software from other OSs
>    (e.g., DOS FDISK, OS/2 FDISK)
> 
> Segmentation fault
> 

This is a working patch, but not an ideal one. We only need to do
the check in functions used by libio from glibc 2.0. We may be able
to optimize it a little bit.


H.J.
----
2000-09-05  H.J. Lu  <hjl@gnu.org>

	* libio/libio.h (_IO_fwide): Add a version for shared library
	to check libio in glibc 2.0.

	* libio/freopen.c (_IO_stdin_used): Removed.
	* libio/oldstdfiles.c: Likewise.

Index: libio/freopen.c
===================================================================
RCS file: /work/cvs/gnu/glibc/libio/freopen.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 freopen.c
--- libio/freopen.c	2000/05/21 21:11:03	1.1.1.1
+++ libio/freopen.c	2000/09/05 21:58:06
@@ -26,11 +26,6 @@
 #include "libioP.h"
 #include "stdio.h"
 
-#ifdef SHARED
-extern void *_IO_stdin_used;
-weak_extern (_IO_stdin_used);
-#endif
-
 #include <shlib-compat.h>
 
 FILE*
Index: libio/libio.h
===================================================================
RCS file: /work/cvs/gnu/glibc/libio/libio.h,v
retrieving revision 1.1.1.5
diff -u -p -r1.1.1.5 libio.h
--- libio/libio.h	2000/09/03 18:03:38	1.1.1.5
+++ libio/libio.h	2000/09/05 22:11:44
@@ -474,7 +474,31 @@ extern int _IO_fwide (_IO_FILE *__fp, in
 # if __GNUC__ >= 2
 /* A special optimized version of the function above.  It optimizes the
    case of initializing an unoriented byte stream.  */
-#  define _IO_fwide(__fp, __mode) \
+#  ifdef SHARED
+extern const int _IO_stdin_used;
+weak_extern (_IO_stdin_used);
+#   define _IO_fwide(__fp, __mode) \
+  ({ int __result;							      \
+     if (&_IO_stdin_used != NULL					      \
+	 || ((__fp) != _IO_stdin && (__fp) != _IO_stdout		      \
+	     && (__fp) != _IO_stderr))					      \
+       {								      \
+	 __result = (__mode);						      \
+	 if (__result < 0)						      \
+	   {								      \
+	     if ((__fp)->_mode == 0)					      \
+	       /* We know that all we have to do is to set the flag.  */      \
+	       (__fp)->_mode = -1;					      \
+	     __result = (__fp)->_mode;					      \
+	   }								      \
+	 else								      \
+	   __result = _IO_fwide (__fp, __result);			      \
+       }								      \
+     else								      \
+	__result = -1;							      \
+     __result; })
+#  else
+#   define _IO_fwide(__fp, __mode) \
   ({ int __result = (__mode);						      \
      if (__result < 0)							      \
        {								      \
@@ -486,6 +510,7 @@ extern int _IO_fwide (_IO_FILE *__fp, in
      else								      \
        __result = _IO_fwide (__fp, __result);				      \
      __result; })
+#  endif
 # endif
 
 extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
Index: libio/oldstdfiles.c
===================================================================
RCS file: /work/cvs/gnu/glibc/libio/oldstdfiles.c,v
retrieving revision 1.1.1.2
diff -u -p -r1.1.1.2 oldstdfiles.c
--- libio/oldstdfiles.c	2000/07/01 19:21:54	1.1.1.2
+++ libio/oldstdfiles.c	2000/09/05 21:58:17
@@ -55,9 +55,6 @@ DEF_STDFILE(_IO_stderr_, 2, &_IO_stdout_
 
 #include <stdio.h>
 
-extern const int _IO_stdin_used;
-weak_extern (_IO_stdin_used);
-
 #undef stdin
 #undef stdout
 #undef stderr

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]