aboutsummaryrefslogtreecommitdiffstats
path: root/tools/genext2fs/patches/400-byteswap_fix.patch
blob: 7b3c00b5ee096da4f467be2eae6b1ff05bb11615 (plain)
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
Index: genext2fs/genext2fs.c
===================================================================
--- genext2fs.orig/genext2fs.c	2011-11-29 17:36:06.000000000 +0100
+++ genext2fs/genext2fs.c	2011-11-29 17:37:37.000000000 +0100
@@ -1779,7 +1779,8 @@
 	assert(nod->i_block[EXT2_DIND_BLOCK] != 0);
 	for(i = 0; i < BLOCKSIZE/4; i++)
 		if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i )
-			swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
+			if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])
+				swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
 	swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]));
 	if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4)
 		return;
@@ -1792,7 +1793,8 @@
 				     (BLOCKSIZE/4)*(BLOCKSIZE/4) + 
 				     i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + 
 				     j*(BLOCKSIZE/4)) ) 
-			  swap_block(get_blk(fs,b2[j]));
+			  if (b2[j])
+			  	swap_block(get_blk(fs,b2[j]));
 			else {
 			  done = 1;
 			  break;
@@ -1825,7 +1827,8 @@
 	swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]));
 	for(i = 0; i < BLOCKSIZE/4; i++)
 		if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i )
-			swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
+			if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])
+				swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
 	if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4)
 		return;
 	/* Adding support for triple indirection */
@@ -1839,7 +1842,8 @@
 				     (BLOCKSIZE/4)*(BLOCKSIZE/4) + 
 				     i*(BLOCKSIZE/4)*(BLOCKSIZE/4) + 
 				     j*(BLOCKSIZE/4)) ) 
-			  swap_block(get_blk(fs,b2[j]));
+			  if (b2[j])
+				swap_block(get_blk(fs,b2[j]));
 			else {
 			  done = 1;
 			  break;