Crash in terminal_screen_has_foreground_process()
@egmontkob
Submitted by Egmont Koblinger Link to original bug (#742560)
Description
https://bugzilla.redhat.com/show_bug.cgi?id=1179515
Program terminated with signal SIGSEGV, Segmentation fault.
`#0` 0x000000000041f1c4 in terminal_screen_has_foreground_process (screen=screen@entry=0x11fd3f0, process_name=process_name@entry=0x7fff36b030e0, cmdline=cmdline@entry=0x7fff36b030d8) at terminal-screen.c:1929
1929 if (data[i] == '\0')
The code is
gsize len;
[...]
g_snprintf (filename, sizeof (filename), "/proc/%d/cmdline", fgpid); if (!g_file_get_contents (filename, &data, &len, NULL)) return TRUE;
[...]
for (i = 0; i < len - 1; i++) { if (data[i] == '\0') data[i] = ' '; }
My only guess is that g_file_get_contents() doesn't include the trailing \0 in len, and the file is empty. So len is 0 and is unsigned, len-1 is freaking huge, hence the loop runs wild. Does this make sense?
Version: git master
Resolution: RESOLVED FIXED