Explorar o código

fixed filename length of temporary attack pcaps exceeding limit (under ubuntu)

Stefano Acquaviti %!s(int64=6) %!d(string=hai) anos
pai
achega
4018b1bdb8
Modificáronse 1 ficheiros con 12 adicións e 4 borrados
  1. 12 4
      code_boost/src/cxx/pcap_processor.cpp

+ 12 - 4
code_boost/src/cxx/pcap_processor.cpp

@@ -52,10 +52,18 @@ std::string pcap_processor::merge_pcaps(const std::string pcap_path) {
     std::string new_filepath = filePath;
     const std::string &newExt = "_" + tstmp + ".pcap";
     std::string::size_type h = new_filepath.rfind('.', new_filepath.length());
-    if (h != std::string::npos) {
-        new_filepath.replace(h, newExt.length(), newExt);
-    } else {
-        new_filepath.append(newExt);
+
+    if ((filePath.length() + newExt.length()) < 250) {
+
+        if (h != std::string::npos) {
+            new_filepath.replace(h, newExt.length(), newExt);
+        } else {
+            new_filepath.append(newExt);
+        }
+    }
+
+    else {
+        new_filepath = (new_filepath.substr(0, new_filepath.find('_'))).append(newExt);
     }
 
     FileSniffer sniffer_base(filePath);