]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer-ftp: Potential memory leak fixed 3864/head
authorJeff Lucovsky <jeff@lucovsky.org>
Sat, 11 May 2019 17:59:16 +0000 (10:59 -0700)
committerVictor Julien <victor@inliniac.net>
Fri, 17 May 2019 10:12:38 +0000 (12:12 +0200)
Ensure that when handling failures during STOR command
processing, that all memory is freed on the error path.

src/app-layer-ftp.c

index a26258ed639965fe06d984457818671764f43d27..6861e20e8adcaaec45fb891d2e674f2ce6b6ac32 100644 (file)
@@ -373,7 +373,7 @@ static void FtpTransferCmdFree(void *data)
     if (cmd == NULL)
         return;
     if (cmd->file_name) {
-        SCFree(cmd->file_name);
+        FTPFree(cmd->file_name, cmd->file_len);
     }
     FTPFree(cmd, sizeof(struct FtpTransferCmd));
 }
@@ -515,7 +515,7 @@ static int FTPParseRequest(Flow *f, void *ftp_state,
                     /* Min size has been checked in FTPParseRequestCommand */
                     data->file_name = FTPCalloc(state->current_line_len - 4, sizeof(char));
                     if (data->file_name == NULL) {
-                        FTPFree(data, sizeof(struct FtpTransferCmd));
+                        FtpTransferCmdFree(data);
                         SCReturnInt(-1);
                     }
                     data->file_name[state->current_line_len - 5] = 0;
@@ -527,7 +527,7 @@ static int FTPParseRequest(Flow *f, void *ftp_state,
                                             state->active ? STREAM_TOSERVER : direction,
                                             0, state->dyn_port, ALPROTO_FTPDATA, data);
                     if (ret == -1) {
-                        FTPFree(data, sizeof(struct FtpTransferCmd));
+                        FtpTransferCmdFree(data);
                         SCLogDebug("No expectation created.");
                         SCReturnInt(-1);
                     } else {