texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Thu, 17 Nov 2022 16:00:39 -0500 (EST)

branch: release/7.0
commit b82f458ef6d29002da3bf3f0cc11641089f7cd39
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Nov 17 19:20:03 2022 +0000

    * info/util.c (text_buffer_iconv): Avoid infinite loop
    by updating space left argument passed to iconv, and by
    continually expanding the allocated space in the output buffer
    if iconv continues to return E2BIG.
    Hang on UTF-8 encoded file with LC_ALL=C reported by
    Hilmar Preuße <hille42@web.de>.
---
 ChangeLog   | 10 ++++++++++
 info/util.c |  6 +++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index c4ae1c3df8..7c44e2bfd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-11-17  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       * info/util.c (text_buffer_iconv): Avoid infinite loop
+       by updating space left argument passed to iconv, and by
+       continually expanding the allocated space in the output buffer
+       if iconv continues to return E2BIG.
+       Hang on UTF-8 encoded file with LC_ALL=C reported by
+       Hilmar Preuße <hille42@web.de>.
+
+
 2022-11-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (%preamble_commands): fix typo on direntry
diff --git a/info/util.c b/info/util.c
index d07262d19b..10be93bae1 100644
--- a/info/util.c
+++ b/info/util.c
@@ -348,6 +348,7 @@ text_buffer_iconv (struct text_buffer *buf, iconv_t 
iconv_state,
   size_t out_bytes_left;
   char *outptr;
   size_t iconv_ret;
+  size_t extra_alloc = 1;
 
   outptr = text_buffer_base (buf) + text_buffer_off (buf);
   out_bytes_left = text_buffer_space_left (buf);
@@ -361,7 +362,10 @@ text_buffer_iconv (struct text_buffer *buf, iconv_t 
iconv_state,
 
       /* If we ran out of space, allocate more and try again. */
       if (errno == E2BIG)
-        text_buffer_alloc (buf, 4);
+        {
+          text_buffer_alloc (buf, (extra_alloc *= 4));
+          out_bytes_left = text_buffer_space_left (buf);
+        }
       else
         break; /* let calling code deal with it */
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]