Skip to content
This repository
Browse code

-FIX: will not insert sig_ref for ""internal"" signature

-FIX: will not fail when there is no reference present in sid-msg.map file.
-UPDATE: Build Version
  • Loading branch information...
commit f0fb22ad7aef66d7f3789748a9b78d33453a43c3 1 parent 880ba85
Eric Lauzon authored June 02, 2012
2  src/barnyard2.h
@@ -63,7 +63,7 @@
63 63
 #define VER_MAJOR		"2"
64 64
 #define VER_MINOR		"1"
65 65
 #define VER_REVISION	"10-beta2"
66  
-#define VER_BUILD		"266"
  66
+#define VER_BUILD		"301"
67 67
 
68 68
 #define STD_BUF  1024
69 69
 
84  src/output-plugins/spo_database_cache.c
@@ -1059,7 +1059,7 @@ u_int32_t ConvertSignatureCache(SigNode **iHead,MasterCache *iMasterCache,Databa
1059 1059
 	    
1060 1060
 	    TobjNode->next = iMasterCache->cacheSignatureHead;
1061 1061
 	    iMasterCache->cacheSignatureHead = TobjNode;
1062  
-	
  1062
+	    	    
1063 1063
 	    if(cNode->refs != NULL)
1064 1064
 	    {
1065 1065
 		if( (ConvertReferenceCache(cNode->refs,iMasterCache,TobjNode,data)))
@@ -4066,7 +4066,7 @@ u_int32_t SystemCacheUpdateDBid(dbSystemObj *iDBList,u_int32_t array_length,cach
4066 4066
             if( (TobjNode = SnortAlloc(sizeof(cacheSystemObj))) == NULL)
4067 4067
             {
4068 4068
                 /* XXX */
4069  
-		printf("Failed to allocate ? \n");
  4069
+		LogMessage("[%s()]: Error Failed to allocate..\n",__FUNCTION__);
4070 4070
                 return 1;
4071 4071
             }
4072 4072
 	    
@@ -4474,13 +4474,14 @@ u_int32_t SystemCacheSynchronize(DatabaseData *data,cacheSystemObj **cacheHead)
4474 4474
     
4475 4475
     u_int32_t array_length = 0;
4476 4476
 
4477  
-    if( (data == NULL) ||
  4477
+    if( (data == NULL)  ||
4478 4478
         (*cacheHead == NULL))
4479 4479
     {
4480 4480
         /* XXX */
4481 4481
         return 1;
4482 4482
     }
4483  
-    
  4483
+
  4484
+
4484 4485
     if( (SystemPullDataStore(data,&dbSysArray,&array_length)))
4485 4486
     {
4486 4487
         /* XXX */
@@ -4627,31 +4628,36 @@ u_int32_t GenerateSigRef(cacheSignatureReferenceObj **iHead,cacheSignatureObj *s
4627 4628
 	return 1;
4628 4629
     }
4629 4630
     
  4631
+    
4630 4632
     while(sigHead != NULL)
4631 4633
     {
4632  
-	for(node_count = 0; node_count < sigHead->obj.ref_count; node_count++)
  4634
+	/* Do not generate sig_ref for internal sig only, since they are not inserted anymore. */
  4635
+	if(sigHead->obj.db_id != 0)
4633 4636
 	{
4634  
-	    memset(&lookupNode,'\0',sizeof(dbSignatureReferenceObj));
4635  
-	    lookupNode.db_ref_id = sigHead->obj.ref[node_count]->obj.ref_id;	 
4636  
-	    lookupNode.db_sig_id = sigHead->obj.db_id;
4637  
-	    lookupNode.ref_seq = (node_count + 1);
4638  
-	    
4639  
-	    if( (cacheSignatureReferenceLookup(&lookupNode,*iHead)) == 0 )
  4637
+	    for(node_count = 0; node_count < sigHead->obj.ref_count; node_count++)
4640 4638
 	    {
4641  
-		if( (newNode = SnortAlloc(sizeof(cacheSignatureReferenceObj))) == NULL)
4642  
-		{
4643  
-		    /* XXX */
4644  
-		    return 1;
4645  
-		}
  4639
+		memset(&lookupNode,'\0',sizeof(dbSignatureReferenceObj));
  4640
+		lookupNode.db_ref_id = sigHead->obj.ref[node_count]->obj.ref_id;	 
  4641
+		lookupNode.db_sig_id = sigHead->obj.db_id;
  4642
+		lookupNode.ref_seq = (node_count + 1);
4646 4643
 		
4647  
-		memcpy(&newNode->obj,&lookupNode,sizeof(dbSignatureReferenceObj));
4648  
-		newNode->flag ^= CACHE_INTERNAL_ONLY;
4649  
-		
4650  
-		newNode->next = *iHead;
4651  
-		*iHead = newNode;
  4644
+		if( (cacheSignatureReferenceLookup(&lookupNode,*iHead)) == 0 )
  4645
+		{
  4646
+		    if( (newNode = SnortAlloc(sizeof(cacheSignatureReferenceObj))) == NULL)
  4647
+		    {
  4648
+			/* XXX */
  4649
+			return 1;
  4650
+		    }
  4651
+		    
  4652
+		    memcpy(&newNode->obj,&lookupNode,sizeof(dbSignatureReferenceObj));
  4653
+		    newNode->flag ^= CACHE_INTERNAL_ONLY;
  4654
+		    
  4655
+		    newNode->next = *iHead;
  4656
+		    *iHead = newNode;
4652 4657
 #if DEBUG
4653  
-		file_sigref_object_count++;
  4658
+		    file_sigref_object_count++;
4654 4659
 #endif
  4660
+		}
4655 4661
 	    }
4656 4662
 	}
4657 4663
         sigHead = sigHead->next;	
@@ -4675,7 +4681,6 @@ u_int32_t GenerateSigRef(cacheSignatureReferenceObj **iHead,cacheSignatureObj *s
4675 4681
 u_int32_t SignatureReferencePullDataStore(DatabaseData *data, dbSignatureReferenceObj **iArrayPtr,u_int32_t *array_length)
4676 4682
 {
4677 4683
     
4678  
-
4679 4684
     u_int32_t curr_row = 0;
4680 4685
     
4681 4686
 #if  (defined(ENABLE_MYSQL) || defined(ENABLE_POSTGRESQL))
@@ -5490,6 +5495,7 @@ u_int32_t SigRefSynchronize(DatabaseData *data,cacheSignatureReferenceObj **cach
5490 5495
     
5491 5496
     /* We initialize the structure in a la */
5492 5497
     if( (GenerateSigRef(cacheHead,cacheSigHead)))
  5498
+    //if( (GenerateSigRef(cacheHead,data->mc.cacheSignatureHead)))
5493 5499
     {
5494 5500
 	/* XXX */
5495 5501
 	return 1;
@@ -5726,23 +5732,29 @@ u_int32_t CacheSynchronize(DatabaseData *data)
5726 5732
     
5727 5733
     
5728 5734
     //System Synchronize
5729  
-    if( (SystemCacheSynchronize(data,&data->mc.cacheSystemHead)))
  5735
+    if(data->mc.cacheSystemHead != NULL)
5730 5736
     {
5731  
-	/* XXX */
5732  
-	LogMessage("[%s()]:, SystemCacheSyncronize() call failed. \n",
5733  
-		   __FUNCTION__);
5734  
-	return 1;
  5737
+	if( (SystemCacheSynchronize(data,&data->mc.cacheSystemHead)))
  5738
+	{
  5739
+	    /* XXX */
  5740
+	    LogMessage("[%s()]:, SystemCacheSyncronize() call failed. \n",
  5741
+		       __FUNCTION__);
  5742
+	    return 1;
  5743
+	}
  5744
+	
  5745
+	//SigRef Synchronize 
  5746
+	if( (SigRefSynchronize(data,&data->mc.cacheSigReferenceHead,data->mc.cacheSignatureHead)))
  5747
+	{
  5748
+	    /* XXX */
  5749
+	    LogMessage("[%s()]: SigRefSynchronize() call failed \n",
  5750
+		       __FUNCTION__);
  5751
+	    return 1;
  5752
+	}
5735 5753
     }
5736  
-    
5737  
-    //SigRef Synchronize 
5738  
-    if( (SigRefSynchronize(data,&data->mc.cacheSigReferenceHead,data->mc.cacheSignatureHead)))
  5754
+    else
5739 5755
     {
5740  
-	/* XXX */
5741  
-	LogMessage("[%s()]: SigRefSynchronize() call failed \n",
5742  
-		   __FUNCTION__);
5743  
-	return 1;
  5756
+	LogMessage("\n[%s()],INFO: No system was found in cache (from signature map file), will not process or synchronize informations found in the database \n\n",__FUNCTION__);
5744 5757
     }
5745  
-
5746 5758
 #if DEBUG
5747 5759
 
5748 5760
     DEBUG_WRAP(DebugMessage(DB_DEBUG,"================================================"

0 notes on commit f0fb22a

Please sign in to comment.
Something went wrong with that request. Please try again.