400-byteswap_fix.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Index: genext2fs/genext2fs.c
  2. ===================================================================
  3. --- genext2fs.orig/genext2fs.c 2011-11-29 17:36:06.000000000 +0100
  4. +++ genext2fs/genext2fs.c 2011-11-29 17:37:37.000000000 +0100
  5. @@ -1779,7 +1779,8 @@
  6. assert(nod->i_block[EXT2_DIND_BLOCK] != 0);
  7. for(i = 0; i < BLOCKSIZE/4; i++)
  8. if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i )
  9. - swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
  10. + if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])
  11. + swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
  12. swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]));
  13. if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4)
  14. return;
  15. @@ -1792,7 +1793,8 @@
  16. (BLOCKSIZE/4)*(BLOCKSIZE/4) +
  17. i*(BLOCKSIZE/4)*(BLOCKSIZE/4) +
  18. j*(BLOCKSIZE/4)) )
  19. - swap_block(get_blk(fs,b2[j]));
  20. + if (b2[j])
  21. + swap_block(get_blk(fs,b2[j]));
  22. else {
  23. done = 1;
  24. break;
  25. @@ -1825,7 +1827,8 @@
  26. swap_block(get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]));
  27. for(i = 0; i < BLOCKSIZE/4; i++)
  28. if(nblk > EXT2_IND_BLOCK + BLOCKSIZE/4 + (BLOCKSIZE/4)*i )
  29. - swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
  30. + if (((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i])
  31. + swap_block(get_blk(fs, ((uint32*)get_blk(fs, nod->i_block[EXT2_DIND_BLOCK]))[i]));
  32. if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4 + BLOCKSIZE/4 * BLOCKSIZE/4)
  33. return;
  34. /* Adding support for triple indirection */
  35. @@ -1839,7 +1842,8 @@
  36. (BLOCKSIZE/4)*(BLOCKSIZE/4) +
  37. i*(BLOCKSIZE/4)*(BLOCKSIZE/4) +
  38. j*(BLOCKSIZE/4)) )
  39. - swap_block(get_blk(fs,b2[j]));
  40. + if (b2[j])
  41. + swap_block(get_blk(fs,b2[j]));
  42. else {
  43. done = 1;
  44. break;