Comment 5 for bug 659115

Revision history for this message
Paulo Matos (pmatos) wrote :

Managed to reproduce this by reducing screen.c from screen. Attached.

Check the interaction:
pmatos@pm18pc01:~/Temp/screen-4.0.3$ gcc -O0 -ggdb -o screen screen.i
screen.i: In function ‘main’:
screen.i:80: warning: assignment makes pointer from integer without a cast
screen.i:82: warning: assignment makes pointer from integer without a cast
pmatos@pm18pc01:~/Temp/screen-4.0.3$ ./screen
Segmentation fault
pmatos@pm18pc01:~/Temp/screen-4.0.3$ gdb screen
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /localhome/pmatos/Temp/screen-4.0.3/screen...done.
(gdb) break main
Breakpoint 1 at 0x40055f: file screen.i, line 80.
(gdb) run
Starting program: /localhome/pmatos/Temp/screen-4.0.3/screen

Breakpoint 1, main (ac=1, av=-7864) at screen.i:80
80 LoginName = getlogin ();
(gdb) n
82 if (LoginName[0] != '\0')
(gdb) p LoginName
$1 = 0xfffffffff7dd8ea0 <Address 0xfffffffff7dd8ea0 out of bounds>

This has got to be a but in getlogin, therefore, probably libc. getlogin either returns a valid char * pointer or NULL or failure but never address out of bounds. Dereferencing it causes the segfault.

It seems the bug is in libc or below it. I have 2.12.1-0ubuntu7.

Can anybody else reproduce this?