]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
suricata: file existence check (bug #2615)
authorDanny Browning <danny.browning@protectwise.com>
Tue, 18 Sep 2018 16:05:03 +0000 (10:05 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 2 Oct 2018 11:39:00 +0000 (13:39 +0200)
Files and directories passed via command line option -r should be checked for
existence during command line parsing and not start additional suricata
functionality.

src/suricata.c

index 0b421bf9ceeb8f5ca70ebad88181cbd0e411f204..cc1a8294ce2319703493026e5fd36364328fa82a 100644 (file)
@@ -2025,8 +2025,18 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
                 PrintUsage(argv[0]);
                 return TM_ECODE_FAILED;
             }
+#ifdef OS_WIN32
+            struct _stat buf;
+            if(_stat(optarg, &buf) != 0) {
+#else
+            struct stat buf;
+            if (stat(optarg, &buf) != 0) {
+#endif /* OS_WIN32 */
+                SCLogError(SC_ERR_INITIALIZATION, "ERROR: Pcap file does not exist\n");
+                return TM_ECODE_FAILED;
+            }
             if (ConfSetFinal("pcap-file.file", optarg) != 1) {
-                fprintf(stderr, "ERROR: Failed to set pcap-file.file\n");
+                SCLogError(SC_ERR_INITIALIZATION, "ERROR: Failed to set pcap-file.file\n");
                 return TM_ECODE_FAILED;
             }