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 118044 - g_log's arg max of 1024 bytes should be chars
g_log's arg max of 1024 bytes should be chars
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.2.x
Other All
: Normal major
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2003-07-22 09:22 UTC by Martyn Russell
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.22 KB, patch)
2003-07-24 23:15 UTC, Matthias Clasen
none Details | Review
remove string length limitation in the non-recursive case (1.58 KB, patch)
2003-07-25 21:03 UTC, Matthias Clasen
none Details | Review

Description Martyn Russell 2003-07-22 09:22:27 UTC
I had a bug reported against my application which basically meant that
information being written to a iochannel was not valid UTF8.  

I narrowed it down, checking the text at every stage and the buffer was
valid UTF8 up until the point I call g_message("%s", buffer) with it.  

The 'buffer' argument is more than 1024 bytes in this particular case, and
when I check the message which has passed through the g_log() functions I
notice that it is no more than 1024 bytes.  

I check the Glib code to find that it has a character array with a maximum
size of 1025 bytes and this array is used in the function _g_vsnprintf(),
on line 437 here:
http://cvs.gnome.org/bonsai/cvsblame.cgi?file=glib%2Fglib/gmessages.c&rev=&root=/cvs/gnome

The problem I face is that I am passing an argument which is more than 1025
bytes and is filled with multibyte characters.  I suspect the reason I get
an "invalid utf8" error is because at the 1024th byte, it is half way
through a (in this case Russian) multibyte character, causing incomplete
UTF8 characters and hence, invalid UTF8.
Comment 1 Matthias Clasen 2003-07-24 23:14:28 UTC
Here is a patch which truncates at a character boundary before the
buffer end.
Comment 2 Matthias Clasen 2003-07-24 23:15:03 UTC
Created attachment 18584 [details] [review]
patch
Comment 3 Martyn Russell 2003-07-25 07:20:43 UTC
Could this be improved to accept unlimited string argument lengths? It
was suggested on the gtk-devel-list@gnome.org, that g_strdup_printf()
could be utilised.

Or has this explicitly NOT been done incase of recursion?

Comment 4 Matthias Clasen 2003-07-25 21:03:03 UTC
Created attachment 18608 [details] [review]
remove string length limitation in the non-recursive case
Comment 5 Matthias Clasen 2003-07-25 23:18:33 UTC
Committed the g_strdup_printf() patch to HEAD.