openbsd-ports/net/snort/patches/patch-src_sfutil_sfxhash_c
lteo 0696392dcc Update to Snort 2.9.5.6, from maintainer Markus Lude.
Special thanks to Bhagya Bantwal of Sourcefire for a patch to fix
crashes on sparc64 on first alert.

Tested on sparc64 by Markus; tested on amd64, i386, and macppc by me.
2013-12-16 03:32:39 +00:00

50 lines
1.7 KiB
Plaintext

$OpenBSD: patch-src_sfutil_sfxhash_c,v 1.1 2013/12/16 03:32:39 lteo Exp $
fix crashes on archs with strict memory alignment, at least sparc64
patch from Bhagya Bantwal from Sourcefire, Thanks!
--- src/sfutil/sfxhash.c.orig Tue Jun 4 23:19:53 2013
+++ src/sfutil/sfxhash.c Tue Dec 3 22:27:24 2013
@@ -235,6 +235,13 @@ SFXHASH * sfxhash_new( int nrows, int keysize, int dat
h->anrfree = anrfree;
h->usrfree = usrfree;
h->keysize = keysize;
+
+#ifdef WORDS_MUSTALIGN
+ if ((h->keysize) & 7)
+ h->pad = (8 - ((h->keysize) & 7));
+#else
+ h->pad = 0;
+#endif
h->datasize = datasize;
h->nrows = nrows;
h->max_nodes = 0;
@@ -579,7 +586,7 @@ SFXHASH_NODE * sfxhash_newnode( SFXHASH * t )
{
if ((t->max_nodes == 0) || (t->count < t->max_nodes))
{
- hnode = (SFXHASH_NODE*)s_alloc( t, sizeof(SFXHASH_NODE) +
+ hnode = (SFXHASH_NODE*)s_alloc( t, sizeof(SFXHASH_NODE) + t->pad +
t->keysize + t->datasize );
}
}
@@ -727,7 +734,7 @@ int sfxhash_add( SFXHASH * t, void * key, void * data
if( t->datasize )
{
/* Set up the new data pointer */
- hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->keysize;
+ hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->pad + t->keysize;
if(data)
{
@@ -806,7 +813,7 @@ SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, const vo
if( t->datasize )
{
/* Set up the new data pointer */
- hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->keysize;
+ hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->pad + t->keysize;
}
else
{