Pārlūkot izejas kodu

Fix out-of-bounds read in FileSystemFilter::Cleanup

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33238
Alex Rebert 3 gadi atpakaļ
vecāks
revīzija
e900617796
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      code/Common/FileSystemFilter.h

+ 3 - 2
code/Common/FileSystemFilter.h

@@ -300,13 +300,14 @@ private:
 
         const char separator = getOsSeparator();
         for (it = in.begin(); it != in.end(); ++it) {
+            int remaining = std::distance(in.end(), it);
             // Exclude :// and \\, which remain untouched.
             // https://sourceforge.net/tracker/?func=detail&aid=3031725&group_id=226462&atid=1067632
-            if ( !strncmp(&*it, "://", 3 )) {
+            if (remaining >= 3 && !strncmp(&*it, "://", 3 )) {
                 it += 3;
                 continue;
             }
-            if (it == in.begin() && !strncmp(&*it, "\\\\", 2)) {
+            if (it == in.begin() && remaining >= 2 && !strncmp(&*it, "\\\\", 2)) {
                 it += 2;
                 continue;
             }