]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unix-manager: fix error and JSON handling
authorEric Leblond <eric@regit.org>
Tue, 20 Nov 2012 09:58:34 +0000 (10:58 +0100)
committerEric Leblond <eric@regit.org>
Tue, 20 Nov 2012 10:05:39 +0000 (11:05 +0100)
src/unix-manager.c

index ec050e027f5fbbbd1713c62f638dd5be030fbd85..62494d41f0d7a44211c8ae9ba306564c705ea74b 100644 (file)
@@ -300,9 +300,10 @@ int UnixCommandAccept(UnixCommand *this)
     }
 
     version = json_object_get(client_msg, "version");
-    if(!json_is_string(version)) {
+    if (!json_is_string(version)) {
         SCLogInfo("error: version is not a string");
         close(client);
+        json_decref(client_msg);
         return 0;
     }
 
@@ -310,6 +311,7 @@ int UnixCommandAccept(UnixCommand *this)
     if (strcmp(json_string_value(version), UNIX_PROTO_VERSION) != 0) {
         SCLogInfo("Unix socket: invalid client version: \"%s\"",
                 json_string_value(version));
+        json_decref(client_msg);
         close(client);
         return 0;
     } else {
@@ -317,6 +319,7 @@ int UnixCommandAccept(UnixCommand *this)
                 json_string_value(version));
     }
 
+    json_decref(client_msg);
     /* send answer */
     server_msg = json_object();
     if (server_msg == NULL) {
@@ -413,6 +416,7 @@ int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client)
             if (fret != TM_ECODE_OK) {
                 ret = 0;
             }
+            break;
         }
     }
 
@@ -441,8 +445,8 @@ int UnixCommandExecute(UnixCommand * this, char *command, UnixClient *client)
     return ret;
 
 error_cmd:
-error:
     json_decref(jsoncmd);
+error:
     json_decref(server_msg);
     UnixCommandClose(this, client->fd);
     return 0;