소스 검색

Update logic on logsuffix matching to remove possibility of infinite loop if the last file in the array does not match logsuffix

sbingner 23 년 전
부모
커밋
64ea9fbce0
1개의 변경된 파일15개의 추가작업 그리고 6개의 파일을 삭제
  1. 15 6
      modules/Pisg/Parser/Logfile.pm

+ 15 - 6
modules/Pisg/Parser/Logfile.pm

@@ -151,16 +151,22 @@ sub _parse_dir
                 push @month, $month;
                 push @month, $month;
             } else {
             } else {
                 splice(@filesarray,$#month + 1, 1);
                 splice(@filesarray,$#month + 1, 1);
-                $file = $filesarray[$#month + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#month + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
             }
             if ($file =~ /$dreg/) {
             if ($file =~ /$dreg/) {
                 push @day, $1;
                 push @day, $1;
             } else {
             } else {
                 splice(@filesarray,$#day + 1, 1);
                 splice(@filesarray,$#day + 1, 1);
                 splice(@month,$#day + 1);
                 splice(@month,$#day + 1);
-                $file = $filesarray[$#day + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#day + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
             }
             if ($file =~ /$yreg/) {
             if ($file =~ /$yreg/) {
                 push @year, $1;
                 push @year, $1;
@@ -168,8 +174,11 @@ sub _parse_dir
                 splice(@filesarray,$#year + 1, 1);
                 splice(@filesarray,$#year + 1, 1);
                 splice(@month,$#year + 1);
                 splice(@month,$#year + 1);
                 splice(@day,$#year + 1);
                 splice(@day,$#year + 1);
-                $file = $filesarray[$#year + 1];
-                goto LOOPSTART;
+                if ($file = $filesarray[$#year + 1]) {
+                    goto LOOPSTART;
+                } else {
+                    last;
+                }
             }
             }
         }
         }
         my @newarray = @filesarray[ sort {
         my @newarray = @filesarray[ sort {