Skip to content

Segmentation fault (read) while loading map in CCollision::Init, collision.cpp:26 #2973

@mmmds

Description

@mmmds

The client crashes when an invalid map (6.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
=================================================================
==33454==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000010 (pc 0x5555559d91ca bp 0x7ffffffd9020 sp 0x7ffffffd9000 T0)
==33454==The signal is caused by a READ memory access.
==33454==Hint: address points to the zero page.
    #0 0x5555559d91c9 in CCollision::Init(CLayers*) /home/osboxes/teeworlds/teeworlds-asan/src/game/collision.cpp:26
    #1 0x5555558398e0 in CGameClient::OnConnected() /home/osboxes/teeworlds/teeworlds-asan/src/game/client/gameclient.cpp:455
    #2 0x5555555f6755 in CClient::ProcessServerPacket(CNetChunk*) /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1283
    #3 0x5555555f91ce in CClient::PumpNetwork() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1596
    #4 0x5555555f9596 in CClient::Update() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:1766
    #5 0x5555555fc1f0 in CClient::Run() /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2108
    #6 0x5555555d24e5 in main /home/osboxes/teeworlds/teeworlds-asan/src/engine/client/client.cpp:2704
    #7 0x7ffff68e10b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #8 0x5555555dc48d in _start (/home/osboxes/teeworlds/teeworlds-asan/build/teeworlds+0x8848d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/osboxes/teeworlds/teeworlds-asan/src/game/collision.cpp:26 in CCollision::Init(CLayers*)
==33454==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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions