Lines 137-143
void Gzip_Compression::start_msg()
Link Here
|
137 |
/************************************************* |
137 |
/************************************************* |
138 |
* Compress Input with Gzip * |
138 |
* Compress Input with Gzip * |
139 |
*************************************************/ |
139 |
*************************************************/ |
140 |
void Gzip_Compression::write(const byte input[], u32bit length) |
140 |
void Gzip_Compression::write(const byte input[], filter_length_t length) |
141 |
{ |
141 |
{ |
142 |
|
142 |
|
143 |
count += length; |
143 |
count += length; |
Lines 267-273
void Gzip_Decompression::start_msg()
Link Here
|
267 |
/************************************************* |
267 |
/************************************************* |
268 |
* Decompress Input with Gzip * |
268 |
* Decompress Input with Gzip * |
269 |
*************************************************/ |
269 |
*************************************************/ |
270 |
void Gzip_Decompression::write(const byte input[], u32bit length) |
270 |
void Gzip_Decompression::write(const byte input[], filter_length_t length) |
271 |
{ |
271 |
{ |
272 |
if(length) no_writes = false; |
272 |
if(length) no_writes = false; |
273 |
|
273 |
|
Lines 284-291
void Gzip_Decompression::write(const byt
Link Here
|
284 |
// Check the gzip header |
284 |
// Check the gzip header |
285 |
if (pos < sizeof(GZIP::GZIP_HEADER)) |
285 |
if (pos < sizeof(GZIP::GZIP_HEADER)) |
286 |
{ |
286 |
{ |
287 |
u32bit len = std::min((u32bit)sizeof(GZIP::GZIP_HEADER)-pos, length); |
287 |
filter_length_t len = std::min((filter_length_t)sizeof(GZIP::GZIP_HEADER)-pos, length); |
288 |
u32bit cmplen = len; |
288 |
filter_length_t cmplen = len; |
289 |
// The last byte is the OS flag - we don't care about that |
289 |
// The last byte is the OS flag - we don't care about that |
290 |
if (pos + len - 1 >= GZIP::HEADER_POS_OS) |
290 |
if (pos + len - 1 >= GZIP::HEADER_POS_OS) |
291 |
cmplen--; |
291 |
cmplen--; |
Lines 346-353
u32bit Gzip_Decompression::eat_footer(co
Link Here
|
346 |
if (footer.size() >= GZIP::FOOTER_LENGTH) |
346 |
if (footer.size() >= GZIP::FOOTER_LENGTH) |
347 |
throw Decoding_Error("Gzip_Decompression: Data integrity error in footer"); |
347 |
throw Decoding_Error("Gzip_Decompression: Data integrity error in footer"); |
348 |
|
348 |
|
|
|
349 |
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11) |
350 |
size_t eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), |
351 |
static_cast<size_t>(length)); |
352 |
footer += std::make_pair(input, eat_len); |
353 |
#else |
349 |
u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length); |
354 |
u32bit eat_len = std::min(GZIP::FOOTER_LENGTH-footer.size(), length); |
350 |
footer.append(input, eat_len); |
355 |
footer.append(input, eat_len); |
|
|
356 |
#endif |
351 |
|
357 |
|
352 |
if (footer.size() == GZIP::FOOTER_LENGTH) |
358 |
if (footer.size() == GZIP::FOOTER_LENGTH) |
353 |
{ |
359 |
{ |
Lines 377-383
void Gzip_Decompression::check_footer()
Link Here
|
377 |
for (int i = 0; i < 4; i++) |
383 |
for (int i = 0; i < 4; i++) |
378 |
buf[3-i] = tmpbuf[i]; |
384 |
buf[3-i] = tmpbuf[i]; |
379 |
|
385 |
|
|
|
386 |
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11) |
387 |
tmpbuf.resize(4); |
388 |
tmpbuf.copy(footer.begin(), 4); |
389 |
#else |
380 |
tmpbuf.set(footer.begin(), 4); |
390 |
tmpbuf.set(footer.begin(), 4); |
|
|
391 |
#endif |
381 |
if (buf != tmpbuf) |
392 |
if (buf != tmpbuf) |
382 |
throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error"); |
393 |
throw Decoding_Error("Gzip_Decompression: Data integrity error - CRC32 error"); |
383 |
|
394 |
|
Lines 412-418
void Gzip_Decompression::clear()
Link Here
|
412 |
no_writes = true; |
423 |
no_writes = true; |
413 |
inflateReset(&(zlib->stream)); |
424 |
inflateReset(&(zlib->stream)); |
414 |
|
425 |
|
|
|
426 |
#if BOTAN_VERSION_CODE >= BOTAN_VERSION_CODE_FOR(1,9,11) |
427 |
footer.clear(); |
428 |
#else |
415 |
footer.destroy(); |
429 |
footer.destroy(); |
|
|
430 |
#endif |
416 |
pos = 0; |
431 |
pos = 0; |
417 |
datacount = 0; |
432 |
datacount = 0; |
418 |
} |
433 |
} |