On 10/06/2013 08:21:41 AM, Tanguy Pruvot wrote:
Bonjour,

  I'm  forwarding  you  a  bug  report from Cyanogenmod project, i can
  reproduce it on the current 1.22 master on my PC too.

  https://jira.cyanogenmod.org/browse/CYAN-1896

If somebody could help us on that, thanks, currently investigating too ..

I wrote the bunzip2 code in busybox way back when, and it theoretically still the same stuff toybox is using, so let's see...

  $ ./toybox bzcat stage3-armv7a_hardfp-20130209.tar.bz2 > stage3.tar
  bzcat: bad data

Interesting. And the ubuntu version works. Ok, stick a printf in there to see which block is failing... block 118.

    /* When we hit the first non-run symbol after a run, we now know
       how many times to repeat the last literal, so append that many
       copies to our buffer of decoded symbols (dbuf) now. (The last
       literal used is the one at the head of the mtfSymbol array.) */
    if (runPos) {
      runPos = 0;
      if (dbufCount+hh >= bd->dbufSize) return RETVAL_DATA_ERROR;

Which is where it's returning, because:
 dbufCount=899973, hh=27, bd->dbufSize=900000

So the run exactly filled up the buffer, but the run had to be terminated by a non-run symbol which _also_ has to go in the buffer? Ah, not if it's the terminating symbol, then it'd break on the next line. So filling up the buffer exactly with a run is ok.

So the fix is to turn the >= into a =. I just fixed it in toybox, and checked that the decompressed output matches what the original implementation does (it does).

Thanks,

Rob
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to