]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/ftp: minor cleanups and fixes
authorJeff Lucovsky <jeff@lucovsky.org>
Sat, 8 Jun 2019 16:29:08 +0000 (12:29 -0400)
committerVictor Julien <victor@inliniac.net>
Wed, 17 Jul 2019 06:21:54 +0000 (08:21 +0200)
src/app-layer-ftp.c
src/output-json-ftp.c

index fbcca8b5cf8046bfd08a08c3b1e20b397efbc930..8e5ce530b2770bb152d307515110354aff396c2e 100644 (file)
@@ -473,9 +473,6 @@ static void FtpTransferCmdFree(void *data)
 static uint32_t CopyCommandLine(uint8_t **dest, uint8_t *src, uint32_t length)
 {
     if (likely(length)) {
-        if (unlikely(length == UINT32_MAX)) {
-            return 0;
-        }
         uint8_t *where = FTPCalloc(length + 1, sizeof(char));
         if (unlikely(where == NULL)) {
             return 0;
@@ -754,7 +751,6 @@ static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstat
                             void *local_data, const uint8_t flags)
 {
     FtpState *state = (FtpState *)ftp_state;
-    FTPTransaction *tx = NULL;
     int retcode = 1;
     FTPTransaction *tx;
 
@@ -774,9 +770,9 @@ static int FTPParseResponse(Flow *f, void *ftp_state, AppLayerParserState *pstat
         tx->command_descriptor = &FtpCommands[FTP_COMMAND_MAX -1];
     } else {
         tx = FTPGetOldestTx(state);
-        state->curr_tx = tx;
     }
 
+    state->curr_tx = tx;
     if (state->command == FTP_COMMAND_AUTH_TLS) {
         if (input_len >= 4 && SCMemcmp("234 ", input, 4) == 0) {
             AppLayerRequestProtocolTLSUpgrade(f);
index 10a9b35e021b6842ce1d1e754af247c79eb80b23..495095861c71d76cfe174307a3a572ebe0c8f621 100644 (file)
@@ -69,13 +69,8 @@ static void JsonFTPLogJSON(json_t *tjs, Flow *f, FTPTransaction *tx)
     } else {
         cjs = json_object();
         if (cjs) {
-            FTPString *response;
-            if (tx->command_descriptor->command == FTP_COMMAND_UNKNOWN) {
-                // alternatively, `command` could be left out of the object completely
-                json_object_set_new(cjs, "command", json_null());
-            } else {
-                json_object_set_new(cjs, "command", json_string(tx->command_descriptor->command_name_upper));
-            }
+            json_object_set_new(cjs, "command",
+                                json_string(tx->command_descriptor->command_name_upper));
             uint32_t min_length = tx->command_descriptor->command_length + 1; /* command + space */
             if (tx->request_length > min_length) {
                 json_object_set_new(cjs, "command_data",