Package: libtextwrap / 0.1-14.2

01-237630-err-in-string.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=237630

From: Thorsten Alteholz <debian@alteholz.de>

This is a small patch to avoid an endless loop. In case of an error 
textwrap() adds <ERR> at the end of the string and returns with the
string that was built up to that error.

diff -u a/textwrap.3 b/textwrap.3
--- a/textwrap.3	2003-08-24 10:13:41.000000000 +0200
+++ b/textwrap.3	2010-01-13 04:59:57.000000000 +0100
@@ -78,6 +78,9 @@
 .SH RETURN VALUE
 \fBtextwrap()\fR returns the line-folded text.
 You can free(3) the given value.
+
+In case of any error while processing the string, the text <ERR> will be
+appended to the output and processing will be aborted.
 .\" ********************************************************************
 .SH EXAMPLE
 .nf
diff -u a/textwrap.c b/textwrap.c
--- a/textwrap.c	2003-08-24 10:13:41.000000000 +0200
+++ b/textwrap.c	2010-01-13 05:04:51.000000000 +0100
@@ -300,6 +300,14 @@
 
     now = p; /* current character */
     ml = mblen(p, MB_CUR_MAX);
+    if (ml<0) {
+       /* 
+	* stringt_addstr will take care about enough
+	* memory for out
+	*/
+       stringt_addstr(out, " <ERR>");
+       return stringt_destroy_extract(out);
+    }
     w = mbwidth(p, ml);
     b = breakable(p, ml, encoding_type);
     p += ml;