[poppler] poppler/PageLabelInfo_p.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 1 22:51:13 UTC 2022


 poppler/PageLabelInfo_p.h |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 42225a1413629c7f3ab8d495267ab9deca485bef
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Apr 2 00:47:12 2022 +0200

    Protect against abnormally long strings

diff --git a/poppler/PageLabelInfo_p.h b/poppler/PageLabelInfo_p.h
index f5f2f7f6..5fa1a5e2 100644
--- a/poppler/PageLabelInfo_p.h
+++ b/poppler/PageLabelInfo_p.h
@@ -3,7 +3,7 @@
 // This file is under the GPLv2 or later license
 //
 // Copyright (C) 2005-2006 Kristian Høgsberg <krh at redhat.com>
-// Copyright (C) 2005, 2009, 2014, 2019, 2020 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005, 2009, 2014, 2019, 2020, 2022 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2011 Simon Kellner <kellner at kit.edu>
 // Copyright (C) 2012 Fabio D'Urso <fabiodurso at hotmail.it>
 // Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
@@ -164,7 +164,6 @@ static void toRoman(int number, GooString *str, bool uppercase)
 
 static int fromLatin(const char *buffer)
 {
-    int count;
     const char *p;
 
     for (p = buffer; *p; p++) {
@@ -173,7 +172,12 @@ static int fromLatin(const char *buffer)
         }
     }
 
-    count = p - buffer;
+    const intptr_t diff = p - buffer;
+    if (unlikely(diff > std::numeric_limits<int>::max() / 100)) {
+        error(errUnimplemented, -1, "Something went wrong in fromLatin conversion");
+        return -1;
+    }
+    const int count = static_cast<int>(diff);
     if (buffer[0] >= 'a' && buffer[0] <= 'z') {
         return 26 * (count - 1) + buffer[0] - 'a' + 1;
     }


More information about the poppler mailing list