After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 520383 - __xmlRaiseError alloc tons of memory and cause segfault
__xmlRaiseError alloc tons of memory and cause segfault
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.31
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-04 21:39 UTC by Mike Hommey
Modified: 2008-04-03 07:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mike Hommey 2008-03-04 21:39:56 UTC
(filed on Debian BTS by mozbugbox@yahoo.com.au)
( http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=456653 )

libxml2 crash liferea on some Chinese RSS feed. Backtrace shows that in
file error.c at XML_GET_VAR_STR(), it realloced too much memory.

With vsnprintf, when it returns -1, there could be all kind of
errors other than just not enough buffer.

In this Chinese feed, the error is

"Invalid or incomplete multibyte or wide character", i.e. EILSEQ.

So if XML_GET_VAR_STR really want to handle pre-glibc 2.1 erorr, it
should check the precise errno first rather blindly realloc more
memory. Otherwise, just break out of the error.

Please see liferea bug:

http://sourceforge.net/tracker/index.php?func=detail&aid=1818306&group_id=87005&atid=581684

This crash can only be see under LC_CTYPE=zh_CN.gbk, under LC_CTYPE=C,
liferea just show a failed to parse error.

Download the file sohu-list-software-0-0.xml attached to the bug report.

Run liferea under LC_CTYPE=zh_CN.gbk

Create a new subscription, point the subscription to local file
(New subscription->Advanced->Local file, select the
sohu-list-software-0-0.xml). Then update feed.
Comment 1 Mike Hommey 2008-03-06 20:40:16 UTC
The problem actually lies in the glibc, and has been known for at least 4 years, but hasn't been considered a bug :(

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=208308
Comment 2 Daniel Veillard 2008-04-03 07:32:22 UTC
Still libxml2 while(1) { ... realloc() } just should be bounded
something like that should be way saner.

paphio:~/XML -> svn diff
Index: error.c
===================================================================
--- error.c     (revision 3721)
+++ error.c     (working copy)
@@ -31,7 +31,7 @@ void XMLCDECL xmlGenericErrorDefaultFunc
                                                                \
     size = 150;                                                        \
                                                                \
-    while (1) {                                                        \
+    while (size < 64000) {                                     \
        va_start(ap, msg);                                      \
        chars = vsnprintf(str, size, msg, ap);                  \
        va_end(ap);                                             \
paphio:~/XML -> 

Commited in revision 3725, if you could check it really fixes
the problem that would be nice.

Daniel