poppler/PageLabelInfo_p.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
New commits: commit 42225a1413629c7f3ab8d495267ab9deca485bef Author: Albert Astals Cid <[email protected]> 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 <[email protected]> -// Copyright (C) 2005, 2009, 2014, 2019, 2020 Albert Astals Cid <[email protected]> +// Copyright (C) 2005, 2009, 2014, 2019, 2020, 2022 Albert Astals Cid <[email protected]> // Copyright (C) 2011 Simon Kellner <[email protected]> // Copyright (C) 2012 Fabio D'Urso <[email protected]> // Copyright (C) 2018 Adam Reichold <[email protected]> @@ -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; }
