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 476840 - Invocation of the interface "g_utf8_strreverse" crashes for certain input values
Invocation of the interface "g_utf8_strreverse" crashes for certain input values
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.14.x
Other Linux
: Normal critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-09-14 09:16 UTC by Areg Beketovski
Modified: 2007-09-14 13:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch, fixing the problem (261 bytes, patch)
2007-09-14 09:58 UTC, Areg Beketovski
none Details | Review

Description Areg Beketovski 2007-09-14 09:16:41 UTC
Steps to reproduce:
1. Invocation of the interface g_utf8_strreverse with 0<len<sizeof(str)-1 results in corruption of memory, due to incorrect while() loop condition.

2. Sample program

#include <glib-2.0/glib.h>

int main()
{
    gchar str[] = "Internet";
    gchar* retValue = g_utf8_strreverse(str,5);
    g_free(retValue);
    return 0;
}


Stack trace:
  • #0 raise
    from /lib64/libc.so.6
  • #1 abort
    from /lib64/libc.so.6
  • #2 __libc_message
    from /lib64/libc.so.6
  • #3 malloc_printerr
    from /lib64/libc.so.6
  • #4 free
    from /lib64/libc.so.6
  • #5 main


Other information:
The detailed bug description can be found at: 

http://linuxtesting.org/results/report?num=D0022
Comment 1 Areg Beketovski 2007-09-14 09:58:12 UTC
Created attachment 95581 [details] [review]
Proposed patch, fixing the problem
Comment 2 Tim Janik 2007-09-14 13:31:58 UTC
(In reply to comment #1)
> Created an attachment (id=95581) [edit]
> Proposed patch, fixing the problem

thanks, please use diff -up next time and try to match the coding style (spaces around operators. fixed with a similar patch now:

2007-09-14 15:07:28  Tim Janik  <timj@gtk.org>

        * glib/gutf8.c (g_utf8_strreverse): applied fix for bug #476840.

        * tests/utf8-pointer.c (test_misc): added test for g_utf8_strreverse().