mime_stats->b64_attachments++;
decoder = new B64Decode(config->get_max_depth(config->get_b64_depth()),
config->get_b64_depth());
+ file_decomp_reset();
return;
}
}
mime_stats->qp_attachments++;
decoder = new QPDecode(config->get_max_depth(config->get_qp_depth()),
config->get_qp_depth());
+ file_decomp_reset();
return;
}
}
mime_stats->uu_attachments++;
decoder = new UUDecode(config->get_max_depth(config->get_uu_depth()),
config->get_uu_depth());
+ file_decomp_reset();
return;
}
}
mime_stats->bitenc_attachments++;
decoder = new BitDecode(config->get_max_depth(config->get_bitenc_depth()),
config->get_bitenc_depth());
+ file_decomp_reset();
return;
}
}
const uint8_t*& buf_out, uint32_t& size_out)
{
DecodeResult result = DECODE_SUCCESS;
+ buf_out = buf_in;
+ size_out = size_in;
- if ( fd_state == nullptr )
- {
- buf_out = buf_in;
- size_out = size_in;
+ if ( (fd_state == nullptr) || (size_in == 0) )
+ return result;
+
+ if ( fd_state->State == STATE_COMPLETE )
return result;
- }
uint8_t* decompress_buf = MimeDecodeContextData::get_decompress_buf();
fd_state->Next_In = buf_in;
// fallthrough
case File_Decomp_NoSig:
case File_Decomp_Error:
- buf_out = buf_in;
- size_out = size_in;
break;
default:
buf_out = decompress_buf;
return result;
}
-MimeDecode::MimeDecode(snort::DecodeConfig* conf)
+void MimeDecode::file_decomp_reset()
{
- config = conf;
+ if ( fd_state == nullptr )
+ return;
+
+ if ( fd_state->State == STATE_READY )
+ return;
+
+ File_Decomp_StopFree(fd_state);
+ fd_state = nullptr;
+ file_decomp_init();
+}
+
+void MimeDecode::file_decomp_init()
+{
bool decompress_pdf = config->is_decompress_pdf();
bool decompress_swf = config->is_decompress_swf();
bool decompress_zip = config->is_decompress_zip();
(void)File_Decomp_Init(fd_state);
}
+MimeDecode::MimeDecode(snort::DecodeConfig* conf)
+{
+ config = conf;
+ file_decomp_init();
+}
+
MimeDecode::~MimeDecode()
{
if (fd_state)