stream-tcp: fix integer warnings

Ticket: 4516
pull/7112/head
Philippe Antoine 4 years ago committed by Victor Julien
parent 068fb700df
commit dca76a45a8

@ -83,8 +83,8 @@ int StreamTcpInlineSegmentCompare(const TcpStream *stream,
SCLogDebug("seq %u, end %u", seq, end);
uint16_t pkt_off = seq - pkt_seq;
uint16_t seg_off = seq - seg->seq;
uint32_t pkt_off = seq - pkt_seq;
uint32_t seg_off = seq - seg->seq;
SCLogDebug("pkt_off %u, seg_off %u", pkt_off, seg_off);
uint32_t range = end - seq;
@ -138,8 +138,8 @@ void StreamTcpInlineSegmentReplacePacket(const TcpStream *stream,
uint32_t seq = (SEQ_LT(pseq, tseq)) ? tseq : pseq;
SCLogDebug("seq %u, end %u", seq, end);
uint16_t poff = seq - pseq;
uint16_t toff = seq - tseq;
uint32_t poff = seq - pseq;
uint32_t toff = seq - tseq;
SCLogDebug("poff %u, toff %u", poff, toff);
uint32_t range = end - seq;

@ -77,7 +77,7 @@ int TcpSegmentCompare(struct TcpSegment *a, struct TcpSegment *b)
static inline int InsertSegmentDataCustom(TcpStream *stream, TcpSegment *seg, uint8_t *data, uint16_t data_len)
{
uint64_t stream_offset;
uint16_t data_offset;
uint32_t data_offset;
if (likely(SEQ_GEQ(seg->seq, stream->base_seq))) {
stream_offset = STREAM_BASE_OFFSET(stream) + (seg->seq - stream->base_seq);
@ -370,8 +370,8 @@ static int DoHandleDataOverlap(TcpStream *stream, const TcpSegment *list,
* data, we have to update buf with the list data */
if (data_is_different && !use_new_data) {
/* we need to copy list into seg */
uint16_t list_offset = 0;
uint16_t seg_offset = 0;
uint32_t list_offset = 0;
uint32_t seg_offset = 0;
uint32_t list_len;
uint16_t seg_len = p->payload_len;
uint32_t list_seq = list->seq;

@ -389,8 +389,7 @@ static int StreamTcpReassemblyConfig(bool quiet)
ConfNode *seg = ConfGetNode("stream.reassembly.segment-prealloc");
if (seg) {
uint32_t prealloc = 0;
if (StringParseUint32(&prealloc, 10, strlen(seg->val), seg->val) < 0)
{
if (StringParseUint32(&prealloc, 10, (uint16_t)strlen(seg->val), seg->val) < 0) {
SCLogError(SC_ERR_INVALID_ARGUMENT, "segment-prealloc of "
"%s is invalid", seg->val);
return -1;
@ -684,7 +683,8 @@ int StreamTcpReassembleHandleSegmentHandleData(ThreadVars *tv, TcpReassemblyThre
SCReturnInt(-1);
}
TCP_SEG_LEN(seg) = size;
DEBUG_VALIDATE_BUG_ON(size > UINT16_MAX);
TCP_SEG_LEN(seg) = (uint16_t)size;
seg->seq = TCP_GET_SEQ(p);
/* HACK: for TFO SYN packets the seq for data starts at + 1 */
@ -1946,7 +1946,8 @@ int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_
*/
TcpSegment *StreamTcpGetSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx)
{
TcpSegment *seg = (TcpSegment *) PoolThreadGetById(segment_thread_pool, ra_ctx->segment_thread_pool_id);
TcpSegment *seg = (TcpSegment *)PoolThreadGetById(
segment_thread_pool, (uint16_t)ra_ctx->segment_thread_pool_id);
SCLogDebug("seg we return is %p", seg);
if (seg == NULL) {
/* Increment the counter to show that we are not able to serve the

@ -688,7 +688,8 @@ static TcpSession *StreamTcpNewSession (Packet *p, int id)
TcpSession *ssn = (TcpSession *)p->flow->protoctx;
if (ssn == NULL) {
p->flow->protoctx = PoolThreadGetById(ssn_pool, id);
DEBUG_VALIDATE_BUG_ON(id < 0 || id > UINT16_MAX);
p->flow->protoctx = PoolThreadGetById(ssn_pool, (uint16_t)id);
#ifdef DEBUG
SCMutexLock(&ssn_pool_mutex);
if (p->flow->protoctx != NULL)
@ -767,7 +768,7 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p)
packets */
ret = SCHInfoGetIPv4HostOSFlavour((uint8_t *)GET_IPV4_DST_ADDR_PTR(p));
if (ret > 0)
stream->os_policy = ret;
stream->os_policy = (uint8_t)ret;
else
stream->os_policy = OS_POLICY_DEFAULT;
@ -777,7 +778,7 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p)
packets */
ret = SCHInfoGetIPv6HostOSFlavour((uint8_t *)GET_IPV6_DST_ADDR(p));
if (ret > 0)
stream->os_policy = ret;
stream->os_policy = (uint8_t)ret;
else
stream->os_policy = OS_POLICY_DEFAULT;
}

@ -2631,8 +2631,7 @@ int PostConfLoadedSetup(SCInstance *suri)
const char *custom_umask;
if (ConfGet("umask", &custom_umask) == 1) {
uint16_t mask;
if (StringParseUint16(&mask, 8, strlen(custom_umask),
custom_umask) > 0) {
if (StringParseUint16(&mask, 8, (uint16_t)strlen(custom_umask), custom_umask) > 0) {
umask((mode_t)mask);
}
}

Loading…
Cancel
Save