Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Linux SDL examples: buffer overflow

Help
2013-01-06
2013-04-25
  • Kim Simmons
    Kim Simmons
    2013-01-06

    Running Ubuntu 12.04 64bit

    Was curious to try out pdcurses and the quickest way seemed to just go for the SDL port since I had that installed.
    It all seems to have compiled fine and the executables are all created from the make file. Unfortunately none of them work!
    Here's the dump I get when I attempted to run testcurs:

    *** buffer overflow detected ***: ./testcurs terminated
    ======= Backtrace: =========
    /lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x37)[0x7ff5657c7807]
    /lib/x86_64-linux-gnu/libc.so.6(+0x109700)[0x7ff5657c6700]
    /lib/x86_64-linux-gnu/libc.so.6(+0x108b69)[0x7ff5657c5b69]
    /lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0xdd)[0x7ff56573913d]
    /lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0xe1)[0x7ff565705aa1]
    /lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x94)[0x7ff5657c5c04]
    /lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7ff5657c5b4d]
    ./testcurs[0x408e81]
    ./testcurs[0x405ca9]
    ./testcurs[0x403ee9]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7ff5656de76d]
    ./testcurs[0x4040e1]
    ======= Memory map: ========
    00400000-00415000 r-xp 00000000 08:06 4493225                            /usr/local/src/PDCurses-3.4/sdl1/testcurs
    00615000-00616000 r--p 00015000 08:06 4493225                            /usr/local/src/PDCurses-3.4/sdl1/testcurs
    00616000-00618000 rw-p 00016000 08:06 4493225                            /usr/local/src/PDCurses-3.4/sdl1/testcurs
    00618000-0061a000 rw-p 00000000 00:00 0 
    00a15000-00a73000 rw-p 00000000 00:00 0                                  [heap]
    7ff55fa97000-7ff55faac000 r-xp 00000000 08:06 1835221                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7ff55faac000-7ff55fcab000 ---p 00015000 08:06 1835221                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7ff55fcab000-7ff55fcac000 r--p 00014000 08:06 1835221                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7ff55fcac000-7ff55fcad000 rw-p 00015000 08:06 1835221                    /lib/x86_64-linux-gnu/libgcc_s.so.1
    7ff55fcad000-7ff55fcae000 ---p 00000000 00:00 0 
    7ff55fcae000-7ff5604ae000 rw-p 00000000 00:00 0 
    7ff5604ae000-7ff5604b3000 r-xp 00000000 08:06 3415329                    /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
    7ff5604b3000-7ff5606b2000 ---p 00005000 08:06 3415329                    /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
    7ff5606b2000-7ff5606b3000 r--p 00004000 08:06 3415329                    /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
    7ff5606b3000-7ff5606b4000 rw-p 00005000 08:06 3415329                    /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
    7ff5606b4000-7ff5606bd000 r-xp 00000000 08:06 3415347                    /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    7ff5606bd000-7ff5608bc000 ---p 00009000 08:06 3415347                    /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    7ff5608bc000-7ff5608bd000 r--p 00008000 08:06 3415347                    /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    7ff5608bd000-7ff5608be000 rw-p 00009000 08:06 3415347                    /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
    7ff5608be000-7ff5608c7000 r-xp 00000000 08:06 3415321                    /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
    7ff5608c7000-7ff560ac6000 ---p 00009000 08:06 3415321                    /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
    7ff560ac6000-7ff560ac7000 r--p 00008000 08:06 3415321                    /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
    7ff560ac7000-7ff560ac8000 rw-p 00009000 08:06 3415321                    /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
    7ff560ac8000-7ff5611ab000 r--p 00000000 08:06 3414590                    /usr/lib/locale/locale-archive
    7ff5611ab000-7ff5611c3000 r-xp 00000000 08:06 1835132                    /lib/x86_64-linux-gnu/libresolv-2.15.so
    7ff5611c3000-7ff5613c3000 ---p 00018000 08:06 1835132                    /lib/x86_64-linux-gnu/libresolv-2.15.so
    7ff5613c3000-7ff5613c4000 r--p 00018000 08:06 1835132                    /lib/x86_64-linux-gnu/libresolv-2.15.so
    7ff5613c4000-7ff5613c5000 rw-p 00019000 08:06 1835132                    /lib/x86_64-linux-gnu/libresolv-2.15.so
    7ff5613c5000-7ff5613c7000 rw-p 00000000 00:00 0 
    7ff5613c7000-7ff5613cd000 r-xp 00000000 08:06 3415724                    /usr/lib/x86_64-linux-gnu/libogg.so.0.7.1
    7ff5613cd000-7ff5615cc000 ---p 00006000 08:06 3415724                    /usr/lib/x86_64-linux-gnu/libogg.so.0.7.1
    7ff5615cc000-7ff5615cd000 r--p 00005000 08:06 3415724                    /usr/lib/x86_64-linux-gnu/libogg.so.0.7.1
    7ff5615cd000-7ff5615ce000 rw-p 00006000 08:06 3415724                    /usr/lib/x86_64-linux-gnu/libogg.so.0.7.1
    7ff5615ce000-7ff5615f9000 r-xp 00000000 08:06 3415882                    /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.5
    7ff5615f9000-7ff5617f8000 ---p 0002b000 08:06 3415882                    /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.5
    7ff5617f8000-7ff5617f9000 r--p 0002a000 08:06 3415882                    /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.5
    7ff5617f9000-7ff5617fa000 rw-p 0002b000 08:06 3415882                    /usr/lib/x86_64-linux-gnu/libvorbis.so.0.4.5
    7ff5617fa000-7ff561aad000 r-xp 00000000 08:06 3415884                    /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2.0.8
    7ff561aad000-7ff561cac000 ---p 002b3000 08:06 3415884                    /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2.0.8
    7ff561cac000-7ff561cc8000 r--p 002b2000 08:06 3415884                    /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2.0.8
    7ff561cc8000-7ff561cc9000 rw-p 002ce000 08:06 3415884                    /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2.0.8
    7ff561cc9000-7ff561d11000 r-xp 00000000 08:06 3415251                    /usr/lib/x86_64-linux-gnu/libFLAC.so.8.2.0
    7ff561d11000-7ff561f11000 ---p 00048000 08:06 3415251                    /usr/lib/x86_64-linux-gnu/libFLAC.so.8.2.0
    7ff561f11000-7ff561f12000 r--p 00048000 08:06 3415251                    /usr/lib/x86_64-linux-gnu/libFLAC.so.8.2.0
    7ff561f12000-7ff561f13000 rw-p 00049000 08:06 3415251                    /usr/lib/x86_64-linux-gnu/libFLAC.so.8.2.0
    7ff561f13000-7ff561f2a000 r-xp 00000000 08:06 1838920                    /lib/x86_64-linux-gnu/libnsl-2.15.so
    7ff561f2a000-7ff562129000 ---p 00017000 08:06 1838920                    /lib/x86_64-linux-gnu/libnsl-2.15.so
    7ff562129000-7ff56212a000 r--p 00016000 08:06 1838920                    /lib/x86_64-linux-gnu/libnsl-2.15.so
    7ff56212a000-7ff56212b000 rw-p 00017000 08:06 1838920                    /lib/x86_64-linux-gnu/libnsl-2.15.so
    7ff56212b000-7ff56212d000 rw-p 00000000 00:00 0 
    7ff56212d000-7ff562132000 r-xp 00000000 08:06 3415325                    /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
    7ff562132000-7ff562331000 ---p 00005000 08:06 3415325                    /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
    7ff562331000-7ff562332000 r--p 00004000 08:06 3415325                    /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
    7ff562332000-7ff562333000 rw-p 00005000 08:06 3415325                    /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
    7ff562333000-7ff562335000 r-xp 00000000 08:06 3415314                    /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
    7ff562335000-7ff562534000 ---p 00002000 08:06 3415314                    /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
    7ff562534000-7ff562535000 r--p 00001000 08:06 3415314                    /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
    7ff562535000-7ff562536000 rw-p 00002000 08:06 3415314                    /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
    7ff562536000-7ff56253b000 r-xp 00000000 08:06 3415371                    /usr/lib/x86_64-linux-gnu/libasyncns.so.0.3.1
    7ff56253b000-7ff56273a000 ---p 00005000 08:06 3415371                    /usr/lib/x86_64-linux-gnu/libasyncns.so.0.3.1
    7ff56273a000-7ff56273b000 r--p 00004000 08:06 3415371                    /usr/lib/x86_64-linux-gnu/libasyncns.so.0.3.1
    7ff56273b000-7ff56273c000 rw-p 00005000 08:06 3415371                    /usr/lib/x86_64-linux-gnu/libasyncns.so.0.3.1
    7ff56273c000-7ff56279c000 r-xp 00000000 08:06 3415819                    /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25
    7ff56279c000-7ff56299c000 ---p 00060000 08:06 3415819                    /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25
    7ff56299c000-7ff56299e000 r--p 00060000 08:06 3415819                    /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25
    7ff56299e000-7ff56299f000 rw-p 00062000 08:06 3415819                    /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.25
    7ff56299f000-7ff5629a3000 rw-p 00000000 00:00 0 
    7ff5629a3000-7ff5629ab000 r-xp 00000000 08:06 1838820                    /lib/x86_64-linux-gnu/libwrap.so.0.7.6
    7ff5629ab000-7ff562baa000 ---p 00008000 08:06 1838820                    /lib/x86_64-linux-gnu/libwrap.so.0.7.6
    7ff562baa000-7ff562bab000 r--p 00007000 08:06 1838820                    /lib/x86_64-linux-gnu/libwrap.so.0.7.6
    7ff562bab000-7ff562bac000 rw-p 00008000 08:06 1838820                    /lib/x86_64-linux-gnu/libwrap.so.0.7.6
    7ff562bac000-7ff562bc2000 r-xp 00000000 08:06 1838822                    /lib/x86_64-linux-gnu/libz.so.1.2.3.4
    7ff562bc2000-7ff562dc1000 ---p 00016000 08:06 1838822                    /lib/x86_64-linux-gnu/libz.so.1.2.3.4
    7ff562dc1000-7ff562dc2000 r--p 00015000 08:06 1838822                    /lib/x86_64-linux-gnu/libz.so.1.2.3.4
    7ff562dc2000-7ff562dc3000 rw-p 00016000 08:06 1838822                    /lib/x86_64-linux-gnu/libz.so.1.2.3.4
    7ff562dc3000-7ff562de5000 r-xp 00000000 08:06 1838808                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
    7ff562de5000-7ff562fe5000 ---p 00022000 08:06 1838808                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
    7ff562fe5000-7ff562fe9000 r--p 00022000 08:06 1838808                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
    7ff562fe9000-7ff562fea000 rw-p 00026000 08:06 1838808                    /lib/x86_64-linux-gnu/libtinfo.so.5.9
    7ff562fea000-7ff563016000 r-xp 00000000 08:06 1838751                    /lib/x86_64-linux-gnu/libncursesw.so.5.9
    7ff563016000-7ff563215000 ---p 0002c000 08:06 1838751                    /lib/x86_64-linux-gnu/libncursesw.so.5.9
    7ff563215000-7ff563216000 r--p 0002b000 08:06 1838751                    /lib/x86_64-linux-gnu/libncursesw.so.5.9
    7ff563216000-7ff563217000 rw-p 0002c000 08:06 1838751                    /lib/x86_64-linux-gnu/libncursesw.so.5.9
    7ff563217000-7ff563308000 r-xp 00000000 08:06 1838801                    /lib/x86_64-linux-gnu/libslang.so.2.2.4
    7ff563308000-7ff563508000 ---p 000f1000 08:06 1838801                    /lib/x86_64-linux-gnu/libslang.so.2.2.4
    7ff563508000-7ff56350c000 r--p 000f1000 08:06 1838801                    /lib/x86_64-linux-gnu/libslang.so.2.2.4
    7ff56350c000-7ff563524000 rw-p 000f5000 08:06 1838801                    /lib/x86_64-linux-gnu/libslang.so.2.2.4
    7ff563524000-7ff563588000 rw-p 00000000 00:00 0 
    7ff563588000-7ff5635a5000 r-xp 00000000 08:06 3409442                    /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
    7ff5635a5000-7ff5637a4000 ---p 0001d000 08:06 3409442                    /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
    7ff5637a4000-7ff5637a5000 r--p 0001c000 08:06 3409442                    /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
    7ff5637a5000-7ff5637a6000 rw-p 0001d000 08:06 3409442                    /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
    7ff5637a6000-7ff5637e8000 r-xp 00000000 08:06 1838647                    /lib/x86_64-linux-gnu/libdbus-1.so.3.5.8Aborted (core dumped)
    

    All get the same error. Some sprintf going rogue and attempting to overflow a buffer.
    Maybe it's a 64bit issue? I'll try to get the X11 one working and see if it does the same.

     
  • It's not a 64-bit issue. I've been using 64-bit Ubuntu since about 2005, and developed the SDL version on that system. :) But as you can see, it's been a while since I tested it…

    I saw this during the build process, when it attempted to link the demos: "/usr/bin/ld: libpdcurses.a(termattr.o)(.text+0x51): unresolvable R_X86_64_32 relocation against symbol `ttytype'". I think the root cause is that in Ubuntu 12.04, libSDL is linked against ncurses. :/ I assume this is for some text-based output, like AAlib.

    I'm not sure what to do about this. In the meantime, you should use the X11 target. (You'll need the CVS version of PDCurses; there's a different problem with X11 in Ubuntu 12.04, and other systems that use recent Xorg versions.)

     
  • Kim Simmons
    Kim Simmons
    2013-01-07

    Thanks for the quick reply!

    I actually managed to get the xcurses to compile and run from the source package from the download section last night. I downloaded the libAwx7-dev package and defined the -x-libraries to the correct lib path for 64bit libs.
    What's the 'different problem with X11' you're talking about? Should I go with the CVS version anyway, or was it just the hardcoded lib-path issue?

    SDL does seem to be a bit of a mess on Ubuntu right now. Do you know if it's difficult to configure and compile an SDL without the ncurses?