All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix hfsplus.
@ 2009-08-22 19:43 Vladimir 'phcoder' Serbinenko
  2009-08-23 11:01 ` Robert Millan
  2009-08-28 13:39 ` Yves Blusseau
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-08-22 19:43 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 256 bytes --]

Hello. In multiple places hfsplus aborts if read_file returns 0. But
in this case grub_error isn't set so the errors aren't propagated.
Here is fix.

-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

[-- Attachment #2: hfsplus.diff --]
[-- Type: text/plain, Size: 2678 bytes --]

diff --git a/fs/hfsplus.c b/fs/hfsplus.c
index 31bb540..5e0ab09 100644
--- a/fs/hfsplus.c
+++ b/fs/hfsplus.c
@@ -469,9 +469,9 @@ grub_hfsplus_mount (grub_disk_t disk)
     grub_be_to_cpu64 (data->volheader.extents_file.size);
 
   /* Read the essential information about the trees.  */
-  if (! grub_hfsplus_read_file (&data->catalog_tree.file, 0,
-				sizeof (struct grub_hfsplus_btnode),
-				sizeof (header), (char *) &header))
+  if (grub_hfsplus_read_file (&data->catalog_tree.file, 0,
+			      sizeof (struct grub_hfsplus_btnode),
+			      sizeof (header), (char *) &header) <= 0)
     goto fail;
 
   data->catalog_tree.root = grub_be_to_cpu32 (header.root);
@@ -479,15 +479,15 @@ grub_hfsplus_mount (grub_disk_t disk)
   data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) &&
 			  (header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE));
 
-  if (! grub_hfsplus_read_file (&data->extoverflow_tree.file, 0,
-				sizeof (struct grub_hfsplus_btnode),
-				sizeof (header), (char *) &header))
+  if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0,
+			      sizeof (struct grub_hfsplus_btnode),
+			      sizeof (header), (char *) &header) <= 0)
     goto fail;
 
   data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
 
-  if (! grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
-				sizeof (node), (char *) &node))
+  if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0,
+			      sizeof (node), (char *) &node) <= 0)
     goto fail;
 
   data->extoverflow_tree.root = grub_be_to_cpu32 (header.root);
@@ -608,10 +608,10 @@ grub_hfsplus_btree_iterate_node (struct grub_hfsplus_btree *btree,
       if (! first_node->next)
 	break;
 
-      if (! grub_hfsplus_read_file (&btree->file, 0,
-				    (grub_be_to_cpu32 (first_node->next)
-				     * btree->nodesize),
-				    btree->nodesize, cnode))
+      if (grub_hfsplus_read_file (&btree->file, 0,
+				  (grub_be_to_cpu32 (first_node->next)
+				   * btree->nodesize),
+				  btree->nodesize, cnode) <= 0)
 	return 1;
 
       /* Don't skip any record in the next iteration.  */
@@ -647,12 +647,12 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
       int match = 0;
 
       /* Read a node.  */
-      if (! grub_hfsplus_read_file (&btree->file, 0,
-				    (long)currnode * (long)btree->nodesize,
-				    btree->nodesize, (char *) node))
+      if (grub_hfsplus_read_file (&btree->file, 0,
+				  (long)currnode * (long)btree->nodesize,
+				  btree->nodesize, (char *) node) <= 0)
 	{
 	  grub_free (node);
-	  return grub_errno;
+	  return grub_error (GRUB_ERR_BAD_FS, "Couldn't read i-node.");
 	}
 
       nodedesc = (struct grub_hfsplus_btnode *) node;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-28 13:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-22 19:43 [PATCH] Fix hfsplus Vladimir 'phcoder' Serbinenko
2009-08-23 11:01 ` Robert Millan
2009-08-28 13:39 ` Yves Blusseau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.