alcjzk / Webserv

0 stars 0 forks source link

Routes are assumed to exist #57

Closed alcjzk closed 6 months ago

alcjzk commented 6 months ago

Problem: Server will SEGV when no root route (\) is configured and no other route matches the request.

Expected behavior: Return 404 not found.

Reproduce: Use config below & request http://localhost:8080/.

Failing config:

[servers.alpha]
    host = 127.0.0.1
    port = 8080
    [servers.alpha.localhost]
        [servers.alpha.localhost.routes./www]
            type = normal
            path = www/
            methods = GET, POST, DELETE
            default_file = index.html

Output:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==58661==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000020 (pc 0x000100f88e34 bp 0x00016eee8cf0 sp 0x00016eee8500 T0)
==58661==The signal is caused by a READ memory access.
==58661==Hint: address points to the zero page.
    #0 0x100f88e34 in Request::process(Connection&&) Request.cpp:108
    #1 0x10101923c in ReceiveRequestTask::receive_headers() ReceiveRequestTask.cpp:142
    #2 0x10101b310 in ReceiveRequestTask::run() ReceiveRequestTask.cpp:181
    #3 0x100f3fd00 in Runtime::run_impl() Runtime.cpp:74
    #4 0x100f3ee18 in Runtime::run() Runtime.cpp:33
    #5 0x1010ee8c0 in main main.cpp:45
    #6 0x189fa90dc  (<unknown module>)

==58661==Register values:
 x[0] = 0x0000000000000000   x[1] = 0x000000016eee7f60   x[2] = 0x0000000104c03e50   x[3] = 0x000000016eee7d48
 x[4] = 0x0000000000000000   x[5] = 0x0000000000000020   x[6] = 0x0000000104c03e50   x[7] = 0x0000000000000001
 x[8] = 0x0000000000000000   x[9] = 0x0000000000000020  x[10] = 0x000000016eee80e0  x[11] = 0x000000702ddfd020
x[12] = 0x000000702ddfcfec  x[13] = 0x000000016eee7b80  x[14] = 0xf2f2f200f2f2f200  x[15] = 0x000000016eee7680
x[16] = 0x000000018a258f34  x[17] = 0x0000000101c045d0  x[18] = 0x0000000000000000  x[19] = 0x000000016eee8940
x[20] = 0x00000001010ed78c  x[21] = 0x000000016eeeb4d0  x[22] = 0x0000000101715910  x[23] = 0x000000016eeeb550
x[24] = 0x000000016eeeb590  x[25] = 0x000000018a02862b  x[26] = 0x0000000000000000  x[27] = 0x0000000000000000
x[28] = 0x0000000000000000     fp = 0x000000016eee8cf0     lr = 0x0000000100f88dcc     sp = 0x000000016eee8500
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV Request.cpp:108 in Request::process(Connection&&)
==58661==ABORTING
zsh: abort      ./bin/debug error_config.tini