]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util action api returns error code if it encounters wrong values parsing wrong action...
authorAnoop Saldanha <poonaatsoc@gmail.com>
Fri, 22 Jun 2012 09:36:55 +0000 (15:06 +0530)
committerVictor Julien <victor@inliniac.net>
Tue, 26 Jun 2012 07:36:10 +0000 (09:36 +0200)
src/suricata.c
src/util-action.c
src/util-action.h

index 7f78bd14580854a2009932a7c163576bce92ab72..d21d035e9b46fbd8c21d5947956fb4c7b141d629 100644 (file)
@@ -1650,7 +1650,9 @@ int main(int argc, char **argv)
     SCClassConfLoadClassficationConfigFile(de_ctx);
     SCRConfLoadReferenceConfigFile(de_ctx);
 
-    ActionInitConfig();
+    if (ActionInitConfig() < 0) {
+        exit(EXIT_FAILURE);
+    }
 
     if (MagicInit() != 0)
         exit(EXIT_FAILURE);
index 4ba1b47a55e68f18a9f8fcbb3588f76d2e43f367..8d8ae66c98499bfdaa2a55b61c9f325fa8ffa4a2 100644 (file)
@@ -90,9 +90,10 @@ uint8_t ActionAsciiToFlag(char *action) {
  * \brief Load the action order from config. If none is provided,
  *        it will be default to ACTION_PASS, ACTION_DROP,
  *        ACTION_REJECT, ACTION_ALERT (pass has the highest prio)
- * \retval none
+ *
+ * \retval 0 on success; -1 on fatal error;
  */
-void ActionInitConfig() {
+int ActionInitConfig() {
     uint8_t actions_used = 0;
     uint8_t action_flag = 0;
     uint8_t actions_config[4] = {0, 0, 0, 0};
@@ -112,7 +113,7 @@ void ActionInitConfig() {
                        " \"pass\",\"drop\",\"alert\",\"reject\". You have"
                        " to specify all of them, without quotes and without"
                        " capital letters", action->val);
-                return;
+                goto error;
             }
 
             if (actions_used & action_flag) {
@@ -120,7 +121,7 @@ void ActionInitConfig() {
                        " use \"pass\",\"drop\",\"alert\",\"reject\". You"
                        " have to specify all of them, without quotes and"
                        " without capital letters", action->val);
-                return;
+                goto error;
             }
 
             if (order >= 4) {
@@ -129,7 +130,7 @@ void ActionInitConfig() {
                        "\"drop\",\"alert\",\"reject\". You have to specify"
                        " all of them, without quotes and without capital"
                        " letters", action->val);
-                return;
+                goto error;
             }
             actions_used |= action_flag;
             actions_config[order++] = action_flag;
@@ -140,13 +141,18 @@ void ActionInitConfig() {
                "actions. Please, use \"pass\",\"drop\",\"alert\","
                "\"reject\". You have to specify all of them, without"
                " quotes and without capital letters");
-                return;
+        goto error;
     }
 
     /* Now, it's a valid config. Override the default preset */
     for (order = 0; order < 4; order++) {
         action_order_sigs[order] = actions_config[order];
     }
+
+    return 0;
+
+ error:
+    return -1;
 }
 
 #ifdef UNITTESTS
index 53aa4caf78b34380b2ab121dad652c5034f34586..bc711314434e6782791d8f2588de733727e63ee1 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef __ACTION_ORDER_H__
 #define __ACTION_ORDER_H__
 #include "suricata-common.h"
-void ActionInitConfig();
+int ActionInitConfig();
 uint8_t ActionOrderVal(uint8_t);
 void UtilActionRegisterTests(void);