Blame SOURCES/djvulibre-3.5.27-infinite-loop.patch

a9380a
From b1f4e1b2187d9e5010cd01ceccf20b4a11ce723f Mon Sep 17 00:00:00 2001
a9380a
From: Leon Bottou <leon@bottou.org>
a9380a
Date: Tue, 26 Mar 2019 20:45:46 -0400
a9380a
Subject: [PATCH] fix for bug #297
a9380a
a9380a
---
a9380a
 libdjvu/DjVmDir.cpp | 2 +-
a9380a
 libdjvu/GBitmap.cpp | 6 ++++--
a9380a
 2 files changed, 5 insertions(+), 3 deletions(-)
a9380a
a9380a
diff --git a/libdjvu/DjVmDir.cpp b/libdjvu/DjVmDir.cpp
a9380a
index 0a0fac6..5a49015 100644
a9380a
--- a/libdjvu/DjVmDir.cpp
a9380a
+++ b/libdjvu/DjVmDir.cpp
a9380a
@@ -309,7 +309,7 @@ DjVmDir::decode(const GP<ByteStream> &gstr)
a9380a
          GP<File> file=files_list[pos];
a9380a
 
a9380a
          if (ptr >= (const char*)strings + strings_size)
a9380a
-           G_THROW( "DjVu document is corrupted (DjVmDir)" );
a9380a
+           G_THROW( ByteStream::EndOfFile );
a9380a
          file->id=ptr;
a9380a
          ptr+=file->id.length()+1;
a9380a
          if (file->flags & File::HAS_NAME)
a9380a
diff --git a/libdjvu/GBitmap.cpp b/libdjvu/GBitmap.cpp
a9380a
index 0e487f0..c2fdbe4 100644
a9380a
--- a/libdjvu/GBitmap.cpp
a9380a
+++ b/libdjvu/GBitmap.cpp
a9380a
@@ -890,11 +890,13 @@ GBitmap::read_rle_raw(ByteStream &bs)
a9380a
   int c = 0;
a9380a
   while (n >= 0)
a9380a
     {
a9380a
-      bs.read(&h, 1);
a9380a
+      if (bs.read(&h, 1) <= 0)
a9380a
+        G_THROW( ByteStream::EndOfFile );
a9380a
       int x = h;
a9380a
       if (x >= (int)RUNOVERFLOWVALUE)
a9380a
         {
a9380a
-          bs.read(&h, 1);
a9380a
+          if (bs.read(&h, 1) <= 0)
a9380a
+            G_THROW( ByteStream::EndOfFile );
a9380a
           x = h + ((x - (int)RUNOVERFLOWVALUE) << 8);
a9380a
         }
a9380a
       if (c+x > ncolumns)
a9380a
-- 
a9380a
2.23.0
a9380a