As some of you may have noticed since v54, Firefox has a long process string `-contentproc -childID 1 -isForBrowser ...` and in this long string there are also non utf-8 characters This creates issue with xfce4-taskmanager, when it is open and there are some Firefox processes, it fills my journald with Invalid UTF-8 string passed to pango_layout_set_text()
Created attachment 7743 normalize string
The actual bug for firefox passing weird tons of parameters on the commandline has been fixed upstream in https://bugzilla.mozilla.org/show_bug.cgi?id=1373157 and https://bugzilla.mozilla.org/show_bug.cgi?id=1438678, but i agree that it's not nice for the taskmanager to not sanitize those strings. Will check Ivan's patch, thanks!
The previous code replaced \r\n by a space, how are you handling this in the string cleaning ?
Bah, stupid me, this is taken care of by g_strcanon() of course..
Rozhuk Ivan referenced this bugreport in commit fd9e313e2e89ed0b81bec8c491842e7032e797ac Make sure only printable characters are used in the pretty cmdline display (bug 14172) https://git.xfce.org/apps/xfce4-taskmanager/commit?id=fd9e313e2e89ed0b81bec8c491842e7032e797ac
Applied, thanks!
Well, at least this patch fixes bug #10417 (I couldn 't reopen that bug, so 3 years ago I just added comment explaining why it is not fixed). But now process with UTF-8 name will be invisible in the taskmanager because all non-ASCII characters will be replaced with spaces. I think proper solution will be to use g_unichar_isprint() for all UTF-8 characters.
And once more again: g_strlcpy() can't be used for overlapping buffers.
Created attachment 7849 more proper utf-8 string normalization
rim referenced this bugreport in commit b89684865d88bbb8399f70387cae9e8ae17d64d9 Better utf-8 normalization (bug 14172) https://git.xfce.org/apps/xfce4-taskmanager/commit?id=b89684865d88bbb8399f70387cae9e8ae17d64d9
(In reply to Ivan 83 from comment #9) > more proper utf-8 string normalization Thanks, I tested this patch and it works for me as expected.
Ivan: fwiw, it seems the last commit (b89684865d88bbb8399f70387cae9e8ae17d64d9) introduces a memory corruption seen with valgrind: ==9038== Invalid read of size 2 ==9038== at 0x4C36750: memmove (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==9038== by 0x11C4A5: memmove (string_fortified.h:40) ==9038== by 0x11C4A5: pretty_cmdline (task-manager.c:175) ==9038== by 0x11C4A5: model_update_tree_iter (task-manager.c:270) ==9038== by 0x11CDD1: model_add_task (task-manager.c:206) ==9038== by 0x11CDD1: xtm_task_manager_update_model (task-manager.c:496) ==9038== by 0x1120B7: init_timeout (main.c:149) ==9038== by 0x111A66: main (main.c:241) ==9038== Address 0x13ded2d4 is 2 bytes after a block of size 18 alloc'd ==9038== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==9038== by 0x6D61578: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1) ==9038== by 0x6D7AAFE: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1) ==9038== by 0x11C333: pretty_cmdline (task-manager.c:130) ==9038== by 0x11C333: model_update_tree_iter (task-manager.c:270) ==9038== by 0x11CDD1: model_add_task (task-manager.c:206) ==9038== by 0x11CDD1: xtm_task_manager_update_model (task-manager.c:496) ==9038== by 0x1120B7: init_timeout (main.c:149) ==9038== Invalid read of size 8 ==9038== at 0x4C367EE: memmove (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==9038== by 0x11C4A5: memmove (string_fortified.h:40) ==9038== by 0x11C4A5: pretty_cmdline (task-manager.c:175) ==9038== by 0x11C4A5: model_update_tree_iter (task-manager.c:270) ==9038== by 0x11CDD1: model_add_task (task-manager.c:206) ==9038== by 0x11CDD1: xtm_task_manager_update_model (task-manager.c:496) ==9038== by 0x1120B7: init_timeout (main.c:149) ==9038== by 0x111A66: main (main.c:241) ==9038== Address 0x13bd14a8 is 2 bytes after a block of size 54 alloc'd ==9038== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==9038== by 0x6D61578: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1) ==9038== by 0x6D7AAFE: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1) ==9038== by 0x11C333: pretty_cmdline (task-manager.c:130) ==9038== by 0x11C333: model_update_tree_iter (task-manager.c:270) ==9038== by 0x11CDD1: model_add_task (task-manager.c:206) ==9038== by 0x11CDD1: xtm_task_manager_update_model (task-manager.c:496) ==9038== by 0x1120B7: init_timeout (main.c:149)
Created attachment 8174 0001-Fix-mem-size-calculation-once-more.patch Memory corruption fixed by commit b4266a20f869d0b57d9309e95b5c5c62f1a9912b, but a terminating null byte should be moved too.