Squashed commit of the following:
commit
14b0e97fa6060bf9dd88db1f3e10aa59aeea4523
Author: Russ Combs <rucombs@cisco.com>
Date: Fri Mar 23 10:25:16 2018 -0400
build: fix various drops const qualifier cases
return false;
}
- // FIXIT-M X This is broken - it should not modify the packet data (which should be const).
- ((ip::IP4Hdr*)(raw.data + codec.lyr_len))->set_proto(IpProtocol::TCP);
+ {
+ // FIXIT-M X This is broken - it should not modify the packet data
+ // (which should be const).
+ const ip::IP4Hdr* iph = reinterpret_cast<const ip::IP4Hdr*>(raw.data + codec.lyr_len);
+ const_cast<ip::IP4Hdr*>(iph)->set_proto(IpProtocol::TCP);
+ }
/* fall through */
case PPP_IP:
of the underlying decompression engine context. */
#ifndef SYNC_IN
#define SYNC_IN(dest) \
- dest->next_in = (Bytef*)(SessionPtr->Next_In); \
+ dest->next_in = const_cast<Bytef*>(SessionPtr->Next_In); \
(dest)->avail_in = SessionPtr->Avail_In; \
(dest)->total_in = SessionPtr->Total_In; \
(dest)->next_out = SessionPtr->Next_Out; \
AltPktHandler() = default;
void handle(DataEvent& e, Flow*) override
- { DetectionEngine::detect((Packet*)e.get_packet()); } // FIXIT-L not const!
+ { DetectionEngine::detect(const_cast<Packet*>(e.get_packet())); }
};
InspectionPolicy::InspectionPolicy(PolicyId id)
if ( ret != Z_OK )
return nullptr;
- stream.next_in = (Bytef*)s;
+ stream.next_in = const_cast<Bytef*>(reinterpret_cast<const uint8_t*>(s));
stream.avail_in = text.size();
stream.next_out = so_buf;
if ( inflateInit2(&stream, window_bits) != Z_OK )
return nullptr;
- stream.next_in = (Bytef*)data;
+ stream.next_in = const_cast<Bytef*>(data);
stream.avail_in = (uInt)len;
stream.next_out = (Bytef*)so_buf;
{
assert(!active_config);
- active_config = new AppIdConfig((AppIdModuleConfig*)config);
+ active_config = new AppIdConfig(const_cast<AppIdModuleConfig*>(config));
DataBus::subscribe(HTTP_REQUEST_HEADER_EVENT_KEY, new HttpEventHandler(
HttpEventHandler::REQUEST_EVENT));
{
if ((compression == CMP_GZIP) || (compression == CMP_DEFLATE))
{
- compress_stream->next_in = (Bytef*)data;
+ compress_stream->next_in = const_cast<Bytef*>(data);
compress_stream->avail_in = length;
compress_stream->next_out = buffer + offset;
compress_stream->avail_out = MAX_OCTETS - offset;
{
// Some incorrect implementations of deflate don't use the expected header. Feed a
// dummy header to zlib and retry the inflate.
- static constexpr char zlib_header[2] = { 0x78, 0x01 };
+ static constexpr uint8_t zlib_header[2] = { 0x78, 0x01 };
inflateReset(compress_stream);
- compress_stream->next_in = (Bytef*)zlib_header;
+ compress_stream->next_in = const_cast<Bytef*>(zlib_header);
compress_stream->avail_in = sizeof(zlib_header);
inflate(compress_stream, Z_SYNC_FLUSH);