diff --git a/cram/cram_codecs.c b/cram/cram_codecs.c index a72419e1c..fe454f794 100644 --- a/cram/cram_codecs.c +++ b/cram/cram_codecs.c @@ -3613,7 +3613,10 @@ int cram_byte_array_stop_decode_block(cram_slice *slice, cram_codec *c, cp = b->data + b->idx; cp_end = b->data + b->uncomp_size; - stop = c->u.byte_array_stop.stop; + // STOP byte is hard-coded as zero by our name tokeniser decoder + // implementation, so we may ignore what was requested. + stop = b->orig_method == TOK3 ? 0 : c->u.byte_array_stop.stop; + if (cp_end - cp < out->alloc - out->byte) { unsigned char *out_cp = BLOCK_END(out); while (cp != cp_end && *cp != stop) diff --git a/cram/cram_io.c b/cram/cram_io.c index 35dbb99c8..5e5891114 100644 --- a/cram/cram_io.c +++ b/cram/cram_io.c @@ -1698,8 +1698,7 @@ int cram_uncompress_block(cram_block *b) { free(uncomp); return -1; } - b->orig_method = RANS_PR0 + (b->data[0]&1) - + 2*((b->data[0]&0x40)>0) + 4*((b->data[0]&0x80)>0); + b->orig_method = RANSPR; free(b->data); b->data = (unsigned char *)uncomp; b->alloc = usize2; @@ -1718,8 +1717,7 @@ int cram_uncompress_block(cram_block *b) { free(uncomp); return -1; } - b->orig_method = ARITH_PR0 + (b->data[0]&1) - + 2*((b->data[0]&0x40)>0) + 4*((b->data[0]&0x80)>0); + b->orig_method = ARITH; free(b->data); b->data = (unsigned char *)uncomp; b->alloc = usize2;