File: fs-xfs-Propagate-incorrect-inode-error-from-grub_xfs_read.patch

package info (click to toggle)
grub2 2.14~git20250718.0e36779-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 60,688 kB
  • sloc: ansic: 541,811; asm: 68,074; sh: 9,803; cpp: 2,095; makefile: 1,895; python: 1,518; sed: 446; lex: 393; yacc: 268; awk: 85; lisp: 54; perl: 31
file content (69 lines) | stat: -rw-r--r-- 2,021 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From: Egor Ignatov <egori@altlinux.org>
Date: Thu, 23 Jan 2025 20:44:15 +0300
Subject: fs/xfs: Propagate incorrect inode error from grub_xfs_read_inode

The incorrect inode error from grub_xfs_read_inode did not propagate because
grub_print_error() resetted grub_errno, and grub_xfs_iterate_dir() did not
handle it at all.

Signed-off-by: Egor Ignatov <egori@altlinux.org>
---
 grub-core/fs/xfs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
index 1bc4017..0fb7d80 100644
--- a/grub-core/fs/xfs.c
+++ b/grub-core/fs/xfs.c
@@ -821,7 +821,6 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
   fdiro = grub_malloc (sz);
   if (!fdiro)
     {
-      grub_print_error ();
       return 0;
     }
 
@@ -833,7 +832,6 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
   err = grub_xfs_read_inode (ctx->diro->data, ino, &fdiro->inode);
   if (err)
     {
-      grub_print_error ();
       grub_free (fdiro);
       return 0;
     }
@@ -873,9 +871,13 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
 	/* Synthesize the direntries for `.' and `..'.  */
 	if (iterate_dir_call_hook (diro->ino, ".", &ctx))
 	  return 1;
+	else if (grub_errno)
+	  return 0;
 
 	if (iterate_dir_call_hook (parent, "..", &ctx))
 	  return 1;
+	else if (grub_errno)
+	  return 0;
 
 	for (i = 0; i < head->count &&
 	     (grub_uint8_t *) de < ((grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)); i++)
@@ -916,6 +918,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
 	      }
 	    de->name[de->len] = c;
 
+	    if (grub_errno)
+	      return 0;
+
 	    de = grub_xfs_inline_next_de(dir->data, head, de);
 	  }
 	break;
@@ -1023,6 +1028,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
 		    grub_free (dirblock);
 		    return 1;
 		  }
+		else if (grub_errno)
+		  {
+		    grub_free (dirblock);
+		    return 0;
+		  }
 
 		/*
 		 * The expected number of directory entries is only tracked for the