From 2496ee620d13940fd444fcea9b86ef9c98e5511b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 18 Oct 2005 11:43:51 +0000 Subject: [PATCH] Make the header removal compressor complain if the start of a frame doesn't match the pattern it should remove. This will have to be improved later if we decide to allow "lossy removal", but for now it is safer. --- src/common/compression.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/common/compression.cpp b/src/common/compression.cpp index 316211e73..38fe2867a 100644 --- a/src/common/compression.cpp +++ b/src/common/compression.cpp @@ -281,20 +281,20 @@ header_removal_compressor_c::compress(memory_cptr &buffer) { buffer->get_size(), m_bytes->get_size())); -// if (memcmp(buffer->get(), m_bytes->get(), m_bytes->get_size())) { -// string b_buffer, b_bytes; -// int i; + if (memcmp(buffer->get(), m_bytes->get(), m_bytes->get_size())) { + string b_buffer, b_bytes; + int i; -// for (i = 0; m_bytes->get_size() > i; ++i) { -// b_buffer += mxsprintf(" %02x", buffer->get()[i]); -// b_bytes += mxsprintf(" %02x", m_bytes->get()[i]); -// } -// throw compression_error_c(mxsprintf("Header removal compression not " -// "possible because the buffer did not " -// "start with the bytes that should be " -// "removed. Wanted bytes:%s; found:%s.", -// b_bytes.c_str(), b_buffer.c_str())); -// } + for (i = 0; m_bytes->get_size() > i; ++i) { + b_buffer += mxsprintf(" %02x", buffer->get()[i]); + b_bytes += mxsprintf(" %02x", m_bytes->get()[i]); + } + throw compression_error_c(mxsprintf("Header removal compression not " + "possible because the buffer did not " + "start with the bytes that should be " + "removed. Wanted bytes:%s; found:%s.", + b_bytes.c_str(), b_buffer.c_str())); + } memmove(buffer->get(), buffer->get() + m_bytes->get_size(), buffer->get_size() - m_bytes->get_size());