texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * info/util.c (text_buffer_iconv): Avoid infinite


From: Gavin D. Smith
Subject: branch master updated: * 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 <address@hidden>.
Date: Thu, 17 Nov 2022 14:20:13 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 353c22d11c * 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>.
353c22d11c is described below

commit 353c22d11c7f4a7b38b570a41bdbe2fe5ed8c945
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 61d04c0e4e..61d4663334 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-16  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/Texinfo.pm,
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]