! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Crash in rstto_file_get_collate_key() when file-name is not in UTF8
Status:
RESOLVED: FIXED
Product:
Ristretto
Component:
Application

Comments

Description Mikhail T. 2016-02-12 04:44:43 CET
The default LANG here is uk_UA.KOI8-U -- not UTF8. When ristretto is asked to display a file with a Cyrillic name (such as, for example, страшила.JPG), it crashes after displaying the image.

The debugger has the following to say:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 2b803080 (LWP 101404/ristretto)]
0x28db7b7d in strlen () from /lib/libc.so.7
(gdb) where
#0  0x28db7b7d in strlen () from /lib/libc.so.7
#1  0x289157f1 in g_utf8_collate_key () from /opt/lib/libglib-2.0.so.0
#2  0x289159f1 in g_utf8_collate_key_for_filename ()
   from /opt/lib/libglib-2.0.so.0
#3  0x08079a6b in rstto_file_get_collate_key (r_file=0x2b983650) at file.c:379
#4  0x08055b5b in cb_rstto_image_list_image_name_compare_func (a=0x2ba306d0, 
    b=0x2b983650) at image_list.c:1359
#5  0x288df15e in g_list_insert_sorted () from /opt/lib/libglib-2.0.so.0
#6  0x288df10c in g_list_insert_sorted () from /opt/lib/libglib-2.0.so.0
#7  0x08053ce5 in rstto_image_list_add_file (image_list=0x2b83f970, 
    r_file=0x2ba306d0, error=0x0) at image_list.c:451
#8  0x080553f2 in cb_rstto_read_file (user_data=0x2bab95c0) at image_list.c:777
#9  0x288df750 in g_list_sort_with_data () from /opt/lib/libglib-2.0.so.0
#10 0x288e326a in g_main_context_dispatch () from /opt/lib/libglib-2.0.so.0
#11 0x288e360f in g_main_context_pending () from /opt/lib/libglib-2.0.so.0
#12 0x288e3961 in g_main_loop_run () from /opt/lib/libglib-2.0.so.0
#13 0x281faff3 in gtk_main () from /opt/lib/libgtk-x11-2.0.so.0
#14 0x080823b4 in main (argc=2, argv=0xbfbfe6f0) at main.c:166
(gdb) frame 3
#3  0x08079a6b in rstto_file_get_collate_key (r_file=0x2b983650) at file.c:379
379                     r_file->priv->collate_key = g_utf8_collate_key_for_filename (casefold, -1);
Current language:  auto; currently minimal
(gdb) p *r_file
$1 = {parent = {g_type_instance = {g_class = 0x2b95ece0}, ref_count = 4, 
    qdata = 0x0}, priv = 0x2b9a5f40}
(gdb) l
374                 /* If we can use casefold for case insenstivie sorting, then
375                  * do so */
376                 gchar *casefold = g_utf8_casefold (basename, -1);
377                 if ( NULL != casefold )
378                 {
379                     r_file->priv->collate_key = g_utf8_collate_key_for_filename (casefold, -1);
380                     g_free (casefold);
381                 }
382                 else
383                 {
(gdb) p casefold
$2 = (gchar *) 0x2cc32460 "Ъ©©©©©Ъ©©©©©Ъ©©©©©Ъ©©©©©.jpg"
(gdb) p basename
$3 = (gchar *) 0x2cc311e0 "страшила.JPG"


It seems, the application assumes UTF8 encoding for all file-names and, probably, is using GLib-functions incorrectly because of that assumption.

If it is at all desirable to sort ignoring case to begin with, why not use the standard tolower(), which is locale-aware?

The ristretto versio is 0.8.0 -- which, for some reason, is not an option in Bugzilla. I'm selecting "master", because file.c in master (as of today) is identical to what's in 0.8.0.
Comment 1 Igor editbugs 2016-10-05 11:15:35 CEST
I've added 0.8.0 to the versions list, thanks.

Bug #12445

Reported by:
Mikhail T.
Reported on: 2016-02-12
Last modified on: 2016-10-05

People

CC List:
1 user

Version

Attachments

Additional information