Hi all!

GRUB has a segfault issue that comes up, when using XFS as the
filesystem for the boot directory and GRUB has been compiled without
writable string support.  With current GCC versions writable string
support is disabled by default and -fwritable-string is deprecated.
Programs should not assume that constant strings, which are stored in
the text area of the program, are writable.

The following three lines from stage2/fsys_xfs.c contain the statements
that causes GRUB to segfault:

Line 337        static char *usual[2] = {".", ".."};
Line 339        char *name = usual[0];
Line 405        name[namelen] = 0;

First we declare usual to contain two constant strings. Then we assign
one of them to name and later we (might) try to write to one character
of the string. Please find attached a patch against current CVS that
transforms usual into an array of characters, so that writing to them is
safe.

Cheers,
Sven

-- 
Sven Wegener
Gentoo Linux Developer
http://www.gentoo.org/
Index: stage2/fsys_xfs.c
===================================================================
RCS file: /cvsroot/grub/grub/stage2/fsys_xfs.c,v
retrieving revision 1.4
diff -u -b -B -r1.4 fsys_xfs.c
--- stage2/fsys_xfs.c   18 Jan 2004 19:47:18 -0000      1.4
+++ stage2/fsys_xfs.c   28 Apr 2005 23:39:08 -0000
@@ -334,7 +334,7 @@
 {
        int namelen = 1;
        int toread;
-       static char *usual[2] = {".", ".."};
+       static char usual[2][3] = {{'.', 0, 0}, {'.', '.', 0}};
        static xfs_dir2_sf_entry_t *sfe;
        char *name = usual[0];
 

Attachment: pgpqUhbcgsgDg.pgp
Description: PGP signature

_______________________________________________
Bug-grub mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-grub

Reply via email to