Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NEY9m-0006iJ-Lw for mharc-grub-devel@gnu.org; Sat, 28 Nov 2009 20:00:54 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NEY9k-0006hJ-2A for grub-devel@gnu.org; Sat, 28 Nov 2009 20:00:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NEY9f-0006eB-9X for grub-devel@gnu.org; Sat, 28 Nov 2009 20:00:51 -0500 Received: from [199.232.76.173] (port=41750 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NEY9f-0006e0-2q for grub-devel@gnu.org; Sat, 28 Nov 2009 20:00:47 -0500 Received: from solo.fdn.fr ([80.67.169.19]:59061) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NEY9e-0007i6-DY for grub-devel@gnu.org; Sat, 28 Nov 2009 20:00:46 -0500 Received: from const.ipv6 (youpi.is-a-geek.org [80.67.176.89]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by solo.fdn.fr (Postfix) with ESMTP id 3099E4428C for ; Sun, 29 Nov 2009 02:00:45 +0100 (CET) Received: from samy by const.ipv6 with local (Exim 4.69) (envelope-from ) id 1NEY9b-0007RY-VS for grub-devel@gnu.org; Sun, 29 Nov 2009 02:00:44 +0100 Date: Sun, 29 Nov 2009 02:00:43 +0100 From: Samuel Thibault To: grub-devel@gnu.org Message-ID: <20091129010043.GK4679@const.famille.thibault.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="A6N2fC+uXW/VQSAv" Content-Disposition: inline User-Agent: Mutt/1.5.12-2006-07-14 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: grub-install crash on GNU/Hurd X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2009 01:00:52 -0000 --A6N2fC+uXW/VQSAv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, grub-install crashes on GNU/Hurd on the stat call in probe(): if (print == PRINT_FS) { struct stat st; stat (path, &st); if (S_ISREG (st.st_mode)) because when grub-probe is passed --device /dev/hd0, path is NULL. This doesn't get noticed on Linux because it returns EFAULT instead of crashing, and by luck S_ISREG() is false. Do people agree on the attached patch, i.e. check that the path is readable only if --device was not given? Samuel --A6N2fC+uXW/VQSAv Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch === modified file 'util/grub-probe.c' --- util/grub-probe.c 2009-11-25 23:10:02 +0000 +++ util/grub-probe.c 2009-11-29 00:58:11 +0000 @@ -238,33 +238,36 @@ if (print == PRINT_FS) { - struct stat st; - - stat (path, &st); - - if (S_ISREG (st.st_mode)) - { - /* Regular file. Verify that we can read it properly. */ - - grub_file_t file; - char *rel_path; - grub_util_info ("reading %s via OS facilities", path); - filebuf_via_sys = grub_util_read_image (path); - - rel_path = make_system_path_relative_to_its_root (path); - asprintf (&grub_path, "(%s)%s", drive_name, rel_path); - free (rel_path); - grub_util_info ("reading %s via GRUB facilities", grub_path); - file = grub_file_open (grub_path); - if (! file) - grub_util_error ("can not open %s via GRUB facilities", grub_path); - filebuf_via_grub = xmalloc (file->size); - grub_file_read (file, filebuf_via_grub, file->size); - - grub_util_info ("comparing"); - - if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size)) - grub_util_error ("files differ"); + if (path) + { + struct stat st; + + stat (path, &st); + + if (S_ISREG (st.st_mode)) + { + /* Regular file. Verify that we can read it properly. */ + + grub_file_t file; + char *rel_path; + grub_util_info ("reading %s via OS facilities", path); + filebuf_via_sys = grub_util_read_image (path); + + rel_path = make_system_path_relative_to_its_root (path); + asprintf (&grub_path, "(%s)%s", drive_name, rel_path); + free (rel_path); + grub_util_info ("reading %s via GRUB facilities", grub_path); + file = grub_file_open (grub_path); + if (! file) + grub_util_error ("can not open %s via GRUB facilities", grub_path); + filebuf_via_grub = xmalloc (file->size); + grub_file_read (file, filebuf_via_grub, file->size); + + grub_util_info ("comparing"); + + if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size)) + grub_util_error ("files differ"); + } } printf ("%s\n", fs->name); --A6N2fC+uXW/VQSAv--