Changeset ba19885


Ignore:
Timestamp:
04/24/15 10:51:04 (6 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
94725ea
Parents:
0054c50
Message:

Fix bug where some LZO traces would have bad checksums

If the 'compressed' block ends up larger than the uncompressed
block, lzop expects you to write the uncompressed block instead.
We were always writing the compressed block, which meant lzop couldn't
process the resulting file properly.

This was common with full payload captures, which don't compress very
well. Header captures were generally unaffected which is why we haven't
noticed this until now.

Thanks to Madhur Srivastava for reporting this problem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libwandio/iow-lzo.c

    rfa7faf3 rba19885  
    207207
    208208        write32(outbuf, len); /* Original length */
    209         write32(outbuf, min((uint32_t)len,(uint32_t)dst_len));
     209       
     210        assert(len > 0);
     211
     212        /* If the compression actually makes the block bigger, we should write out the
     213         * block uncompressed. */
     214        if (dst_len < (uint32_t)len)
     215                write32(outbuf, (uint32_t)dst_len);
     216        else
     217                write32(outbuf, len);
    210218        /* CRC32 of the uncompressed buffer */
    211219#if 0
     
    214222        write32(outbuf,
    215223                lzo_adler32(ADLER32_INIT_VALUE, (const void*)buffer, len));
    216         write_buf(outbuf, b2, dst_len);
     224       
     225        if (dst_len < (uint32_t)len)
     226                write_buf(outbuf, b2, dst_len);
     227        else
     228                write_buf(outbuf, buffer, len);
    217229
    218230        /* Return the number of bytes compressed */
     
    424436                                assert(get_next_thread(iow)->outbuf.offset
    425437                                                < sizeof(get_next_thread(iow)->outbuf.buffer));
     438                               
    426439                                wandio_wwrite(DATA(iow)->child,
    427440                                                get_next_thread(iow)->outbuf.buffer,
     
    452465                        if (get_next_thread(iow)->inbuf.offset >= sizeof(get_next_thread(iow)->inbuf.buffer)
    453466                          ||get_next_thread(iow)->inbuf.offset >= MAX_BLOCK_SIZE) {
    454                                 assert(get_next_thread(iow)->state == EMPTY);
     467                                assert(get_next_thread(iow)->state == EMPTY);
    455468                                get_next_thread(iow)->state = WAITING;
    456469                                pthread_cond_signal(&get_next_thread(iow)->in_ready);
Note: See TracChangeset for help on using the changeset viewer.