Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault (read) while loading map in CGraphics_Threaded::LoadTextureRaw, graphics_threaded.cpp:375 #2980

Open
mmmds opened this issue Oct 23, 2021 · 0 comments · May be fixed by #2931

Comments

@mmmds
Copy link

mmmds commented Oct 23, 2021

The client crashes when an invalid map (13.map.zip) is loaded. Such a map can be delivered to the client by a malicious server.

Tested on Ubuntu 20.04 x86_64, Teeworlds version: f35da54b6f2c5f9fd4bbd4559f887ccf8f8cc526

Compilation with ASAN:

export CXXFLAGS="-ggdb -O0 -fsanitize=address -fno-omit-frame-pointer"
export CFLAGS="-ggdb -O0 -fsanitize=address -fno-omit-frame-pointer"
cmake ..
make

Run and connect to a server that delivers an invalid map:

./teeworlds "connect 127.0.0.1" "gfx_fullscreen 0" "gfx_screen_height 240" "gfx_screen_width 360"
[...]
AddressSanitizer:DEADLYSIGNAL
=================================================================
==33741==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ffff6978ec8 bp 0x7ffffffd8b60 sp 0x7ffffffd82c8 T0)
==33741==The signal is caused by a READ memory access.
==33741==Hint: address points to the zero page.
    #0 0x7ffff6978ec7  (/lib/x86_64-linux-gnu/libc.so.6+0xbeec7)
    #1 0x7ffff761c36e  (/lib/x86_64-linux-gnu/libasan.so.5+0x9b36e)
    #2 0x55555560adb6 in CGraphics_Threaded::LoadTextureRaw(int, int, int, void const*, int, int) /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/graphics_threaded.cpp:375
    #3 0x5555556f49a3 in CMapImages::LoadMapImages(IMap*, CLayers*, int) /home/osboxes/teeworlds/teeworlds-asan/src/game/client/components/mapimages.cpp:61
    #4 0x555555839981 in CGameClient::OnConnected() /home/osboxes/teeworlds/teeworlds-asan/src/game/client/gameclient.cpp:459
    #5 0x5555555f6755 in CClient::ProcessServerPacket(CNetChunk*) /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1283
    #6 0x5555555f91ce in CClient::PumpNetwork() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1596
    #7 0x5555555f9596 in CClient::Update() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1766
    #8 0x5555555fc1f0 in CClient::Run() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2108
    #9 0x5555555d24e5 in main /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2704
    #10 0x7ffff68e10b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #11 0x5555555dc48d in _start (/home/osboxes/teeworlds/teeworlds-asan/build/teeworlds+0x8848d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0xbeec7) 
==33741==ABORTING

Compilation without ASAN:

export CXXFLAGS="-ggdb -O0"
export CFLAGS="-ggdb -O0"
cmake ..
make

Run and connect to a server that delivers an invalid map:

./teeworlds "connect 127.0.0.1" "gfx_fullscreen 0" "gfx_screen_height 240" "gfx_screen_width 360"
[...]
Segmentation fault (core dumped)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants