Permalink
Browse files

Merge pull request #61 from binf/bug-fix

Fix: Call to memcmp in signature_reference code.
  • Loading branch information...
2 parents 07174fc + 722737a commit f57e46466c2e23cfa07c9726fb83a3f42e02a925 @firnsy committed Jan 18, 2013
Showing with 12 additions and 3 deletions.
  1. +1 −1 src/barnyard2.h
  2. +8 −0 src/output-plugins/spo_database.c
  3. +3 −2 src/output-plugins/spo_database_cache.c
View
@@ -63,7 +63,7 @@
#define VER_MAJOR "2"
#define VER_MINOR "1"
#define VER_REVISION "11"
-#define VER_BUILD "317"
+#define VER_BUILD "318"
#define STD_BUF 1024
@@ -3683,13 +3683,21 @@ int Select(char * query, DatabaseData * data,u_int32_t *rval)
ErrorMessage("ERROR database: Query [%s] returned more than one result\n",
query);
result = 0;
+ PQclear(data->p_result);
+ data->p_result = NULL;
return 1;
}
else
{
*rval = atoi(PQgetvalue(data->p_result,0,0));
}
}
+ else
+ {
+ PQclear(data->p_result);
+ data->p_result = NULL;
+ return 1;
+ }
}
if(!result)
@@ -897,7 +897,7 @@ u_int32_t ConvertReferenceCache(ReferenceNode *iHead,MasterCache *iMasterCache,c
refFound = 0;
for(tItr=0; tItr < cSobj->obj.ref_count; tItr++)
{
- if( (memcmp(&cSobj->obj.ref[tItr]->obj,&retRefLookupNode->obj,sizeof(dbReferenceObj))) )
+ if( (memcmp(&cSobj->obj.ref[tItr]->obj,&retRefLookupNode->obj,sizeof(dbReferenceObj))) == 0)
{
refFound = 1;
break;
@@ -5345,7 +5345,7 @@ u_int32_t SignatureReferenceCacheUpdateDBid(dbSignatureReferenceObj *iDBList,
*/
u_int32_t SignatureReferencePopulateDatabase(DatabaseData *data,cacheSignatureReferenceObj *cacheHead)
{
- u_int32_t row_validate;
+ u_int32_t row_validate = 0;
if( (data == NULL))
{
@@ -5380,6 +5380,7 @@ u_int32_t SignatureReferencePopulateDatabase(DatabaseData *data,cacheSignatureRe
{
if(cacheHead->flag & CACHE_INTERNAL_ONLY)
{
+ row_validate = 0;
#if DEBUG
inserted_sigref_object_count++;

0 comments on commit f57e464

Please sign in to comment.