]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ftp: rearrange command struct to be more compact
authorVictor Julien <vjulien@oisf.net>
Wed, 26 Apr 2023 05:34:14 +0000 (07:34 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 26 Apr 2023 05:42:13 +0000 (07:42 +0200)
./app-layer-ftp.h:92:16: warning: Excessive padding in 'struct FtpCommand_' (11 padding bytes, where 3 is optimal). Optimal fields order: command_name, command, command_length, consider reordering the fields or adding explicit padding members [optin.performance.Padding]
typedef struct FtpCommand_ {
        ~~~~~~~^~~~~~~~~~~~~

src/app-layer-ftp.c
src/app-layer-ftp.h

index 4f7ed0b16baf56e7d85ba877e26555b6de8f30bf..a47b0502ed593d9cff1ff0587a8fe512281e0f0e 100644 (file)
@@ -47,60 +47,63 @@ typedef struct FTPThreadCtx_ {
 
 static MpmCtx *ftp_mpm_ctx = NULL;
 
+// clang-format off
 const FtpCommand FtpCommands[FTP_COMMAND_MAX + 1] = {
     /* Parsed and handled */
-    { FTP_COMMAND_PORT, "PORT", 4},
-    { FTP_COMMAND_EPRT, "EPRT", 4},
-    { FTP_COMMAND_AUTH_TLS, "AUTH TLS", 8},
-    { FTP_COMMAND_PASV, "PASV", 4},
-    { FTP_COMMAND_RETR, "RETR", 4},
-    { FTP_COMMAND_EPSV, "EPSV", 4},
-    { FTP_COMMAND_STOR, "STOR", 4},
+    { "PORT",   FTP_COMMAND_PORT,   4 },
+    { "EPRT",   FTP_COMMAND_EPRT,   4 },
+    { "AUTH TLS",   FTP_COMMAND_AUTH_TLS,   8 },
+    { "PASV",   FTP_COMMAND_PASV,   4 },
+    { "RETR",   FTP_COMMAND_RETR,   4 },
+    { "EPSV",   FTP_COMMAND_EPSV,   4 },
+    { "STOR",   FTP_COMMAND_STOR,   4 },
 
     /* Parsed, but not handled */
-    { FTP_COMMAND_ABOR, "ABOR", 4},
-    { FTP_COMMAND_ACCT, "ACCT", 4},
-    { FTP_COMMAND_ALLO, "ALLO", 4},
-    { FTP_COMMAND_APPE, "APPE", 4},
-    { FTP_COMMAND_CDUP, "CDUP", 4},
-    { FTP_COMMAND_CHMOD, "CHMOD", 5},
-    { FTP_COMMAND_CWD, "CWD", 3},
-    { FTP_COMMAND_DELE, "DELE", 4},
-    { FTP_COMMAND_HELP, "HELP", 4},
-    { FTP_COMMAND_IDLE, "IDLE", 4},
-    { FTP_COMMAND_LIST, "LIST", 4},
-    { FTP_COMMAND_MAIL, "MAIL", 4},
-    { FTP_COMMAND_MDTM, "MDTM", 4},
-    { FTP_COMMAND_MKD, "MKD", 3},
-    { FTP_COMMAND_MLFL, "MLFL", 4},
-    { FTP_COMMAND_MODE, "MODE", 4},
-    { FTP_COMMAND_MRCP, "MRCP", 4},
-    { FTP_COMMAND_MRSQ, "MRSQ", 4},
-    { FTP_COMMAND_MSAM, "MSAM", 4},
-    { FTP_COMMAND_MSND, "MSND", 4},
-    { FTP_COMMAND_MSOM, "MSOM", 4},
-    { FTP_COMMAND_NLST, "NLST", 4},
-    { FTP_COMMAND_NOOP, "NOOP", 4},
-    { FTP_COMMAND_PASS, "PASS", 4},
-    { FTP_COMMAND_PWD, "PWD", 3},
-    { FTP_COMMAND_QUIT, "QUIT", 4},
-    { FTP_COMMAND_REIN, "REIN", 4},
-    { FTP_COMMAND_REST, "REST", 4},
-    { FTP_COMMAND_RMD, "RMD", 3},
-    { FTP_COMMAND_RNFR, "RNFR", 4},
-    { FTP_COMMAND_RNTO, "RNTO", 4},
-    { FTP_COMMAND_SITE, "SITE", 4},
-    { FTP_COMMAND_SIZE, "SIZE", 4},
-    { FTP_COMMAND_SMNT, "SMNT", 4},
-    { FTP_COMMAND_STAT, "STAT", 4},
-    { FTP_COMMAND_STOU, "STOU", 4},
-    { FTP_COMMAND_STRU, "STRU", 4},
-    { FTP_COMMAND_SYST, "SYST", 4},
-    { FTP_COMMAND_TYPE, "TYPE", 4},
-    { FTP_COMMAND_UMASK, "UMASK", 5},
-    { FTP_COMMAND_USER, "USER", 4},
-    { FTP_COMMAND_UNKNOWN, NULL, 0}
+    { "ABOR",   FTP_COMMAND_ABOR,   4 },
+    { "ACCT",   FTP_COMMAND_ACCT,   4 },
+    { "ALLO",   FTP_COMMAND_ALLO,   4 },
+    { "APPE",   FTP_COMMAND_APPE,   4 },
+    { "CDUP",   FTP_COMMAND_CDUP,   4 },
+    { "CHMOD",  FTP_COMMAND_CHMOD,  5 },
+    { "CWD",    FTP_COMMAND_CWD,    3 },
+    { "DELE",   FTP_COMMAND_DELE,   4 },
+    { "HELP",   FTP_COMMAND_HELP,   4 },
+    { "IDLE",   FTP_COMMAND_IDLE,   4 },
+    { "LIST",   FTP_COMMAND_LIST,   4 },
+    { "MAIL",   FTP_COMMAND_MAIL,   4 },
+    { "MDTM",   FTP_COMMAND_MDTM,   4 },
+    { "MKD",    FTP_COMMAND_MKD,    3 },
+    { "MLFL",   FTP_COMMAND_MLFL,   4 },
+    { "MODE",   FTP_COMMAND_MODE,   4 },
+    { "MRCP",   FTP_COMMAND_MRCP,   4 },
+    { "MRSQ",   FTP_COMMAND_MRSQ,   4 },
+    { "MSAM",   FTP_COMMAND_MSAM,   4 },
+    { "MSND",   FTP_COMMAND_MSND,   4 },
+    { "MSOM",   FTP_COMMAND_MSOM,   4 },
+    { "NLST",   FTP_COMMAND_NLST,   4 },
+    { "NOOP",   FTP_COMMAND_NOOP,   4 },
+    { "PASS",   FTP_COMMAND_PASS,   4 },
+    { "PWD",    FTP_COMMAND_PWD,    3 },
+    { "QUIT",   FTP_COMMAND_QUIT,   4 },
+    { "REIN",   FTP_COMMAND_REIN,   4 },
+    { "REST",   FTP_COMMAND_REST,   4 },
+    { "RMD",    FTP_COMMAND_RMD,    3 },
+    { "RNFR",   FTP_COMMAND_RNFR,   4 },
+    { "RNTO",   FTP_COMMAND_RNTO,   4 },
+    { "SITE",   FTP_COMMAND_SITE,   4 },
+    { "SIZE",   FTP_COMMAND_SIZE,   4 },
+    { "SMNT",   FTP_COMMAND_SMNT,   4 },
+    { "STAT",   FTP_COMMAND_STAT,   4 },
+    { "STOU",   FTP_COMMAND_STOU,   4 },
+    { "STRU",   FTP_COMMAND_STRU,   4 },
+    { "SYST",   FTP_COMMAND_SYST,   4 },
+    { "TYPE",   FTP_COMMAND_TYPE,   4 },
+    { "UMASK",  FTP_COMMAND_UMASK,  5 },
+    { "USER",   FTP_COMMAND_USER,   4 },
+    { NULL,     FTP_COMMAND_UNKNOWN,    0 }
 };
+// clang-format on
+
 uint64_t ftp_config_memcap = 0;
 uint32_t ftp_config_maxtx = 1024;
 uint32_t ftp_max_line_len = 4096;
index 2a3cbf4cb7f4879753ebcb4f86eaec32100e5b52..cc6a744543967d10a957d127205ced7997421a80 100644 (file)
@@ -90,8 +90,8 @@ typedef enum {
 } FtpRequestCommand;
 
 typedef struct FtpCommand_ {
-    FtpRequestCommand command;
     const char *command_name;
+    FtpRequestCommand command;
     const uint8_t command_length;
 } FtpCommand;
 extern const FtpCommand FtpCommands[FTP_COMMAND_MAX + 1];