summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch')
-rw-r--r--meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch76
1 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch
new file mode 100644
index 0000000000..0ef162c023
--- /dev/null
+++ b/meta/recipes-devtools/genext2fs/genext2fs-1.4.1/fix-memory-corruption-on-powerpc.patch
@@ -0,0 +1,76 @@
1Upstream-Status: Submitted
2
3fix memory corruption on powerpc
4
5Signed-off-by: Wrobel Heinz <Heinz.Wrobel@freescale.com>
6
7diff --unified a/genext2fs.c b/genext2fs.c
8--- a/genext2fs.c 2013-08-14 16:50:59.061623605 +0200
9+++ b/genext2fs.c 2013-08-14 16:47:23.349623674 +0200
10@@ -675,21 +675,34 @@
11 }
12
13 static void
14-swap_nod(inode *nod)
15+swap_nod(inode *nod, int fromdisk)
16 {
17 uint32 nblk;
18+ uint32 i_blocks = nod->i_blocks;
19+ uint32 i_size = nod->i_size;
20+ uint16 i_mode = nod->i_mode;
21+
22
23 #define this nod
24 inode_decl
25 #undef this
26
27+ if (fromdisk) {
28+ // Only now do we have the values in the correct
29+ // endianess for the host. So we override the
30+ // earlier assumption
31+ i_blocks = nod->i_blocks;
32+ i_size = nod->i_size;
33+ i_mode = nod->i_mode;
34+ }
35+
36 // block and character inodes store the major and minor in the
37 // i_block, so we need to unswap to get those. Also, if it's
38 // zero iblocks, put the data back like it belongs.
39- nblk = nod->i_blocks / INOBLK;
40- if ((nod->i_size && !nblk)
41- || ((nod->i_mode & FM_IFBLK) == FM_IFBLK)
42- || ((nod->i_mode & FM_IFCHR) == FM_IFCHR))
43+ nblk = i_blocks / INOBLK;
44+ if ((i_size && !nblk)
45+ || ((i_mode & FM_IFBLK) == FM_IFBLK)
46+ || ((i_mode & FM_IFCHR) == FM_IFCHR))
47 {
48 int i;
49 for(i = 0; i <= EXT2_TIND_BLOCK; i++)
50@@ -1066,7 +1079,7 @@
51 nod_info *ni = container_of(elem, nod_info, link);
52
53 if (ni->fs->swapit)
54- swap_nod(ni->itab);
55+ swap_nod(ni->itab, 0);
56 put_blk(ni->bi);
57 free(ni);
58 }
59@@ -1102,7 +1115,7 @@
60 ni->b = get_blk(fs, fs->gd[grp].bg_inode_table + boffset, &ni->bi);
61 ni->itab = ((inode *) ni->b) + offset;
62 if (fs->swapit)
63- swap_nod(ni->itab);
64+ swap_nod(ni->itab, 1);
65
66 out:
67 *rni = ni;
68@@ -1158,6 +1171,8 @@
69 if (dw->fs->swapit)
70 swap_dir(&dw->d);
71 memcpy(dw->last_d, &dw->d, sizeof(directory));
72+ if (dw->fs->swapit)
73+ swap_dir(&dw->d);
74
75 if (((int8 *) next_d) >= ((int8 *) dw->b + BLOCKSIZE))
76 return NULL;