livefacter / firmware-mod-kit

Automatically exported from code.google.com/p/firmware-mod-kit
0 stars 0 forks source link

CramFS extraction failed due to missing cleaning up #134

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
While trying to extract a CramFS filesystem with binwalk, I narrowed down the 
extraction failure to one script: uncramfs_all.sh

Here is what happens (traced through a "bash -x"):
1. the script tries to extract it with LZMA compression and fails because this 
particular one is not compressed with LZMA.
2. then a cramfsck occurs and returns an exit code of 4
3. It tries to extract it with uncramfs which, launched manually succeeds but 
as the script did not cleaned up the extracted files from the LZMA attempt, it 
fails because files already exists.

Unsure about the need of cleaning also before calling cramfsck.

Here is a working patch:
diff --git a/uncramfs_all.sh b/uncramfs_all.sh
index 7b8a7af..f67242d 100755
--- a/uncramfs_all.sh
+++ b/uncramfs_all.sh
@@ -105,6 +105,7 @@ then
      exit 0
   fi

+  rm -rf "$ROOTFS"
   ./src/uncramfs/uncramfs "$ROOTFS" "$FSIMG.le" 2>/dev/null
   if [ $? -eq 0 ]
   then

Original issue reported on code.google.com by jmiche...@gmail.com on 21 Jul 2014 at 8:14