struct Pseudoheader6
{
-- uint32_t sip[4], dip[4];
++ uint32_t sip[4];
++ uint32_t dip[4];
uint8_t zero;
uint8_t protocol;
uint16_t len;
struct Pseudoheader
{
-- uint32_t sip, dip;
++
++ uint32_t sip;
++ uint32_t dip;
uint8_t zero;
uint8_t protocol;
uint16_t len;
namespace detail
{
++
++struct PsuedoheaderUnion
++{
++ union
++ {
++ Pseudoheader ph4;
++ uint16_t ph4_arr[12];
++ };
++};
++
++struct Psuedoheader6Union
++{
++ union
++ {
++ Pseudoheader ph6;
++ uint16_t ph6_arr[18];
++ };
++};
++
static inline uint16_t cksum_add(const uint16_t *buf, std::size_t len, uint32_t cksum)
{
const uint16_t *sp = buf;
}
--static inline void add_ipv4_pseudoheader(const uint16_t* const h,
++static inline void add_ipv4_pseudoheader(const Pseudoheader* const ph4,
uint32_t &cksum)
{
++ /*
++ * This mess is necessary to make static analyzers happy.
++ * Otherwise they assume we are reading garbage values
++ */
++ const PsuedoheaderUnion* const ph4_u = reinterpret_cast
++ <const PsuedoheaderUnion* const>(ph4);
++ const uint16_t* const h = ph4_u->ph4_arr;
++
/* ipv4 pseudo header must have 12 bytes */
cksum += h[0];
cksum += h[1];
}
--static inline void add_ipv6_pseudoheader(const uint16_t* const h,
++static inline void add_ipv6_pseudoheader(const Pseudoheader6* const ph6,
uint32_t &cksum)
{
-- /* PseudoHeader must have 36 bytes */
-- cksum += h[0];
-- cksum += h[1];
-- cksum += h[2];
-- cksum += h[3];
-- cksum += h[4];
-- cksum += h[5];
-- cksum += h[6];
-- cksum += h[7];
-- cksum += h[8];
-- cksum += h[9];
-- cksum += h[10];
-- cksum += h[11];
-- cksum += h[12];
-- cksum += h[13];
-- cksum += h[14];
-- cksum += h[15];
-- cksum += h[16];
-- cksum += h[17];
++ /*
++ * This mess is necessary to make static analyzers happy.
++ * Otherwise they assume we are reading garbage values
++ */
++ const Psuedoheader6Union* const ph6_u = reinterpret_cast
++ <const Psuedoheader6Union* const>(ph6);
++ const uint16_t* const h = ph6_u->ph6_arr;
++
++ /* PseudoHeader must have 36 bytes */
++ cksum += h[0];
++ cksum += h[1];
++ cksum += h[2];
++ cksum += h[3];
++ cksum += h[4];
++ cksum += h[5];
++ cksum += h[6];
++ cksum += h[7];
++ cksum += h[8];
++ cksum += h[9];
++ cksum += h[10];
++ cksum += h[11];
++ cksum += h[12];
++ cksum += h[13];
++ cksum += h[14];
++ cksum += h[15];
++ cksum += h[16];
++ cksum += h[17];
}
{
uint32_t cksum = 0;
-- detail::add_ipv6_pseudoheader((const uint16_t* const)ph, cksum);
++ detail::add_ipv6_pseudoheader(ph, cksum);
return detail::cksum_add(buf, len, cksum);
}
{
uint32_t cksum = 0;
-- detail::add_ipv4_pseudoheader((const uint16_t* const)ph, cksum);
++ detail::add_ipv4_pseudoheader(ph, cksum);
detail::add_tcp_header(h, len, cksum);
return detail::cksum_add(h, len, cksum);
}
{
uint32_t cksum = 0;
-- detail::add_ipv6_pseudoheader((const uint16_t* const)ph, cksum);
++ detail::add_ipv6_pseudoheader(ph, cksum);
detail::add_tcp_header(buf, len, cksum);
return detail::cksum_add(buf, len, cksum);
}
{
uint32_t cksum = 0;
-- detail::add_ipv4_pseudoheader((const uint16_t* const)ph, cksum);
++ detail::add_ipv4_pseudoheader(ph, cksum);
detail::add_udp_header(buf, len, cksum);
return detail::cksum_add(buf, len, cksum);
}
{
uint32_t cksum = 0;
-- detail::add_ipv6_pseudoheader((const uint16_t* const)ph, cksum);
++ detail::add_ipv6_pseudoheader(ph, cksum);
detail::add_udp_header(buf, len, cksum);
return detail::cksum_add(buf, len, cksum);
}
return false;
}
-- ip_len = ntohs(ip4h->get_len());/* set the IP datagram length */
hlen = ip4h->get_hlen() << 2; /* set the IP header length */
if(raw_len < hlen)
ParseError("content hexmode argument has invalid "
"number of hex digits. The argument '%s' "
"must contain a full even byte string.", current_ptr);
++ free(hex);
return (uint8_t*)"";
}
else
{
ParseError("'%c' is not a valid hex value, please input hex values (0x0 - 0xF)",
-- (char) *current_ptr);
++ (char) *current_ptr);
++ free(hex);
return (uint8_t*)"";
}
else
{
ParseError("'%c' is not a valid hex value, please input hex values (0x0 - 0xF)",
-- (char) *current_ptr);
++ (char) *current_ptr);
++ free(hex);
return (uint8_t*)"";
}
DEBUG_WRAP(DebugMessage(DEBUG_FILE,"Hex buffer: %s\n", hex_buf););
if (file_config->FileRules[rule->id])
{
ParseError("file type: duplicated rule id %d defined!", rule->id);
++ free(rule);
return;
}
file_config->FileRules[rule->id] = rule;
}
if (j < opts_len)
-- TextLog_Print(log, "%02x", opts[i].data[j]);
++ TextLog_Print(log, "%02x", 0);
}
TextLog_Putc(log, ' ');
mod_ctor,
mod_dtor
},
-- (OUTPUT_TYPE_FLAG__LOG | OUTPUT_TYPE_FLAG__ALERT),
++ OUTPUT_TYPE_FLAG__LOG,
codec_log_ctor,
codec_log_dtor
};
state = 3;
break;
case 5: // unquoted escape
-- if ( c == '\n' )
-- state = 0;
-- else if ( c != '\r' )
++ if ( c != '\n' && c != '\r' )
printf("error: invalid escape on line %d\n", lines);
state = 0;
break;
#include "config.h"
#endif
++#include <string>
++#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hi_util_xmalloc.h"
//#define MEMASSERT(p) if(!p){printf("KMAP-No Memory: File: %s Line:%d!\n",__FILE__,__LINE__);exit(0);}
--
#define MEMASSERT(p)
--#define LOWERCASE tolower
++
/*
*
*/
int KMapAdd( KMAP *km, void * key, int n, void * userdata )
{
-- int i,ksize;
-- int type = 0;
-- unsigned char *P = (unsigned char *)key;
-- KMAPNODE *root;
-- unsigned char xkey[256];
++ int i,ksize;
++ int type = 0;
++ const unsigned char *P = (unsigned char *)key;
++ KMAPNODE *root;
++ std::string xkey;
if( n <= 0 )
{
-- n = strlen( (char*) key );
-- if( n > (int)sizeof(xkey) )
++ std::size_t tmp_len = strlen( (char*) key);
++ if (tmp_len > std::numeric_limits<int>::max())
return -99;
++
++ n = tmp_len;
}
if( km->nocase )
{
++ xkey.resize(n);
++
for(i=0;i<n;i++)
-- xkey[i] = LOWERCASE( P[i] );
-- P = xkey;
++ xkey[i] = std::tolower( P[i] );
++
++ P = (const unsigned char*) xkey.c_str();
}
/* Save key size */
*/
void * KMapFind( KMAP * ks, void * key, int n )
{
-- unsigned char * T = (unsigned char *)key;
-- KMAPNODE * root;
-- unsigned char xkey[256];
-- int i;
++ const unsigned char * T = (unsigned char *)key;
++ KMAPNODE * root;
++ std::string xkey;
++ int i;
if( n <= 0 )
{
-- n = strlen( (char*)key );
-- if( n > (int)sizeof(xkey) )
-- return 0;
++ std::size_t tmp_len = strlen( (char*) key);
++ if (tmp_len > std::numeric_limits<int>::max())
++ return nullptr;
++ n = tmp_len;
}
++
if( ks->nocase )
{
++ xkey.resize(n);
for(i=0;i<n;i++)
-- xkey[i] = LOWERCASE( T[i] );
++ xkey[i] = std::tolower( T[i] );
-- T = xkey;
++ T = (const unsigned char*)(xkey.c_str());
}
//printf("finding key='%.*s'\n",n,T);
#include "config.h"
#endif
++#include <string>
++#include <limits>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hi_util_xmalloc.h"
//#define MEMASSERT(p) if(!p){printf("KMAP-No Memory: File: %s Line:%d!\n",__FILE__,__LINE__);exit(0);}
--
#define MEMASSERT(p)
--#define LOWERCASE tolower
/*
*
{
int i,ksize;
int type = 0;
-- unsigned char *P = (unsigned char *)key;
++ const unsigned char *P = (unsigned char *)key;
KMAPNODE *root;
-- unsigned char xkey[256];
++ std::string xkey;
if( n <= 0 )
{
-- n = strlen( (char*) key );
-- if( n > (int)sizeof(xkey) )
++ const std::size_t tmp_len = strlen( (char*) key);
++ if (tmp_len > std::numeric_limits<int>::max())
return -99;
++
++ n = (int) tmp_len;
}
if( km->nocase )
{
++ xkey.resize(n);
++
for(i=0;i<n;i++)
-- xkey[i] = LOWERCASE( P[i] );
-- P = xkey;
++ xkey[i] = std::tolower( P[i] );
++
++ P = (const unsigned char*)xkey.c_str();
}
/* Save key size */
*/
void * KMapFind( KMAP * ks, void * key, int n )
{
-- unsigned char * T = (unsigned char *)key;
-- KMAPNODE * root;
-- unsigned char xkey[256];
-- int i;
++ const unsigned char * T = (unsigned char *)key;
++ KMAPNODE * root;
++ int i;
++ std::string xkey;
if( n <= 0 )
{
-- n = strlen( (char*)key );
-- if( n > (int)sizeof(xkey) )
-- return 0;
++ const std::size_t tmp_len = strlen( (char*) key);
++ if (tmp_len > std::numeric_limits<int>::max())
++ return nullptr;
++ n = (int) tmp_len;
}
++
if( ks->nocase )
{
++ xkey.resize(n);
for(i=0;i<n;i++)
-- xkey[i] = LOWERCASE( T[i] );
++ xkey[i] = std::tolower( T[i] );
-- T = xkey;
++ T = (const unsigned char*)xkey.c_str();
}
//printf("finding key='%.*s'\n",n,T);
if(!table || !str || !ipret) return SFIP_FAILURE;
/* Creates the variable */
-- if( (var = sfvar_alloc(table, str, &status)) == NULL )
++ var = sfvar_alloc(table, str, &status);
++ if( var == NULL )
{
return status;
}
if(cc < 0)
{
ParseError("read %s: %s\n", fname, get_error(errno));
++ free(cp);
return nullptr;
}
if(cc != buf.st_size)
{
ParseError("short read %s (%d != %d)\n", fname, cc, (int) buf.st_size);
++ free(cp);
return nullptr;
}
{
ParseError("SetChroot: Can not chdir to \"%s\": %s\n", directory,
get_error(errno));
++ free(logdir);
return;
}
if(absdir == NULL)
{
ParseError("NULL Chroot found\n");
++ free(logdir);
return;
}
{
ParseError("Can not chroot to \"%s\": absolute: %s: %s\n",
directory, absdir, get_error(errno));
++ free(logdir);
return;
}
{
ParseError("Can not chdir to \"/\" after chroot: %s\n",
get_error(errno));
++ free(logdir);
return;
}
if(strncmp(absdir, logdir, strlen(absdir)))
{
ParseError("Absdir is not a subset of the logdir");
++ free(logdir);
return;
}
logdir, *logstore));
LogMessage("Chroot directory = %s\n", directory);
++ free(logdir);
}
int PNormDecode(char *src, uint16_t srclen, char *dst, uint16_t dstlen, uint16_t *bytes_copied, JSState *js)
{
-- int iRet;
++ int iRet = RET_OK;
const char *end;
char *ptr;
PNormState s;
int JSNormalizeDecode(char *src, uint16_t srclen, char *dst, uint16_t destlen, char **ptr, int *bytes_copied, JSState *js, uint8_t* iis_unicode_map)
{
-- int iRet;
++ int iRet = RET_OK;
const char *start, *end;
JSNormState s;