OSSP CVS Repository

ossp - Check-in [1044]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1044
Date: 2001-Sep-28 16:28:41 (local)
2001-Sep-28 14:28:41 (UTC)
User:ms
Branch:
Comment: Fixed bug of incorrectly checking the result of a call to pcre_study(), and later testing the return of pcre_exec(). Added code to test the filter channel.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_ch_filter.c      1.9 -> 1.10     6 inserted, 4 deleted
ossp-pkg/l2/l2_test.c      1.27 -> 1.28     12 inserted, 2 deleted

ossp-pkg/l2/l2_ch_filter.c 1.9 -> 1.10

--- l2_ch_filter.c       2001/09/25 09:35:17     1.9
+++ l2_ch_filter.c       2001/09/28 14:28:41     1.10
@@ -83,7 +83,8 @@
             return L2_ERR_ARG;
         }
         /* study FSM for more performance */
-        if ((cfg->pcreExtra = pcre_study(cfg->pcreRegex, 0, &szError)) == NULL) {
+        cfg->pcreExtra = pcre_study(cfg->pcreRegex, 0, &szError);
+        if (szError != NULL) {
             free(cfg->pcreRegex);
             cfg->pcreRegex = NULL;
             l2_channel_errorinfo(ch, L2_ERR_ARG, "%s", szError);
@@ -101,13 +102,14 @@
     l2_ch_filter_t *cfg = (l2_ch_filter_t *)ctx->vp;
     l2_channel_t *downstream = l2_channel_downstream(ch);
     l2_result_t rv;
-    int bPass;
+    int bPass, iCheck;
 
     bPass = TRUE;
 
     /* apply filter */
-    if (cfg->pcreRegex != NULL && cfg->pcreExtra != NULL) {
-       if (pcre_exec(cfg->pcreRegex, cfg->pcreExtra, buf, buf_size, 0, 0, NULL, 0) > 0)
+    if (cfg->pcreRegex != NULL) {
+       iCheck = pcre_exec(cfg->pcreRegex, cfg->pcreExtra, buf, buf_size, 0, 0, NULL, 0);
+       if (iCheck >= 0)
            bPass = TRUE;
        else
            bPass = FALSE;


ossp-pkg/l2/l2_test.c 1.27 -> 1.28

--- l2_test.c    2001/09/21 17:30:26     1.27
+++ l2_test.c    2001/09/28 14:28:41     1.28
@@ -63,6 +63,7 @@
 
 int main(int argc, char *argv[])
 {
+    l2_channel_t *chFilt;
     l2_channel_t *chPrefix;
     l2_channel_t *chBuf;
     l2_channel_t *chFile;
@@ -92,6 +93,12 @@
     if (l2_channel_configure(chPrefix, "prefix,timezone", "[%d-%m-%Y/%H:%M:%S] %L test[%P]: ", "local") != L2_OK)
         die("failed to configure prefix channel");
 
+    if ((chFilt = l2_channel_create(&l2_handler_filter)) == NULL)    /* Filter */
+        die("failed to create filter channel");
+
+    if (l2_channel_configure(chFilt, "regex,negate", "hecking", 0) != L2_OK)
+        die("failed to configure filter channel");
+
     if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL)    /* Buffer */
         die("failed to create buffer channel");
 
@@ -110,10 +117,13 @@
     if (l2_channel_stack(chBuf, chPrefix) != L2_OK)
         die("failed to stack prefix channel on top of buffer channel");
 
-    if (l2_channel_open(chPrefix) != L2_OK)
+    if (l2_channel_stack(chPrefix, chFilt) != L2_OK)
+        die("failed to stack filter channel on top of prefix channel");
+    
+    if (l2_channel_open(chFilt) != L2_OK)
         die("failed to open channel stack");
 
-    if (l2_stream_channel(st, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK)
+    if (l2_stream_channel(st, chFilt, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK)
         die("failed to attach channel stack into stream");
 
 #ifdef WITH_SYSLOG

CVSTrac 2.0.1