{"id":5775,"date":"2025-08-31T02:54:44","date_gmt":"2025-08-31T02:54:44","guid":{"rendered":"https:\/\/www.voodoo.business\/blog\/?p=5775"},"modified":"2025-08-31T03:05:22","modified_gmt":"2025-08-31T03:05:22","slug":"sanity-checks-for-bz2-files-before-decompression","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2025\/08\/31\/sanity-checks-for-bz2-files-before-decompression\/","title":{"rendered":"Sanity check for BZ2 files before decompression"},"content":{"rendered":"\n<p>To check if a file integrity is intact without expanding it, you can try the obvious send to \/dev\/null or use a built in equivilent<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bzip2 -dc file.bz2 &gt; \/dev\/null<br>bzip2 -tv file.bz2<\/pre>\n\n\n\n<p>Now, the problem can be that the split files were not complete ! so when i executed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat file.bz2.001 file.bz2.002 file.bz2.003 file.bz2.004 &gt; file.bz2<\/pre>\n\n\n\n<p>I thought that 004 was the last part, but it was not, how can i know without wasting CPU cycles ! let me show you<\/p>\n\n\n\n<p>NOTE: If you have not yet concatenated the files, you can do the header checks on the first file, and the footer checks on the last \ud83d\ude09 in my case, I already have them concatenated (Not a problem, i can add more files to it later) so i am doing both checks on the same file<\/p>\n\n\n\n<p>Check the header, Every bzip2 file starts with: 42 5a 68 xx<\/p>\n\n\n\n<p><code>head -c4 file.bz2 | hexdump -C<\/code><\/p>\n\n\n\n<p>Should result in <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">00000000  42 5a 68 39                                       |BZh9|<\/pre>\n\n\n\n<p>And it does<\/p>\n\n\n\n<p>But when i check the footer with the command<\/p>\n\n\n\n<p>tail -c64 file.tar.bz2 | hexdump -C<\/p>\n\n\n\n<p>The first line of that output should be<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">00000000  17 72 45 38 50 90 00 00  00 00 00 00 00 00 00 00  |.rE8P...........|<\/pre>\n\n\n\n<p>But it is not, in my case it was <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">00000000  e4 fc 2e 36 2f e7 d5 bf  74 d5 3b 0f ef 4a 61 15  |...6\/...t.;..Ja.|<\/pre>\n\n\n\n<p>Which looks like random compressed data<\/p>\n\n\n\n<p>In conclusion, I should find all the other parts to be concatinated to this before wasting time decompressing it <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To check if a file integrity is intact without expanding it, you can try the obvious send to \/dev\/null or use a built in equivilent bzip2 -dc file.bz2 &gt; \/dev\/nullbzip2 -tv file.bz2 Now, the problem can be that the split files were not complete ! so when i executed cat file.bz2.001 file.bz2.002 file.bz2.003 file.bz2.004 &gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-5775","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/5775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=5775"}],"version-history":[{"count":5,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/5775\/revisions"}],"predecessor-version":[{"id":5781,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/5775\/revisions\/5781"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=5775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=5775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=5775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}