Server crashes if given HTTP version cannot be cast to float, or the resulting float is too large
Issue
If given HTTP version string cannot be cast to a float, the server will crash. The server will also crash if the string can be cast to a float, but the resulting number is too large.
How to replicate:
Run the server
Open terminal, type:
telnet localhost 8080 GET / HTTP/NotNumericString
OR
telnet localhost 8080 GET / HTTP/10000000000000000000.10000000000000000000000000000000
Stack Trace:
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff705f8b1 in __GI_abort () at abort.c:79
#2 0x00007ffff76b4957 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007ffff76baae6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007ffff76bab21 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007ffff76bad54 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff76b67eb in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00005555556625b3 in __gnu_cxx::__stoa<float, float, char> (__convf=0x7ffff7065070 <__GI_strtof>,
__name=0x5555556b3036 "stof", __str=0x555555900250 "enpunkten", __idx=0x0)
at /usr/include/c++/7/ext/string_conversions.h:83
#8 0x0000555555655a5a in std::__cxx11::stof (__str="enpunkten", __idx=0x0)
at /usr/include/c++/7/bits/basic_string.h:6398
#9 0x000055555566f55f in SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::write(std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Session> const&, std::function<void (std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response>, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Request>)>&)::{lambda(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*)#1}::operator()(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*) const::{lambda(boost::system::error_code const&)#1}::operator()(boost::system::error_code const) const (__closure=0x5555558fe260, ec=...)
at /mnt/c/users/Thomas/Documents/Skole/3ING/TDAT3020/Øving 2/buggy-web-server/server_http.hpp:765
#10 0x000055555567b594 in std::_Function_handler<void (boost::system::error_code const&), SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::write(std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Session> const&, std::function<void (std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response>, std::shared_ptr<SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Request>)>&)::{lambda(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*)#1}::operator()(SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response*) const::{lambda(boost::system::error_code const&)#1}>::_M_invoke(std::_Any_data const&, boost::system::error_code const&) (__functor=..., __args#0=...) at /usr/include/c++/7/bits/std_function.h:316
#11 0x000055555567b719 in std::function<void (boost::system::error_code const&)>::operator()(boost::system::error_code const&) const (this=0x7fffffffd6e0, __args#0=...) at /usr/include/c++/7/bits/std_function.h:706
#12 0x000055555567516b in SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}::operator()(boost::system::error_code const&, unsigned long) const (__closure=0x7fffffffd6d0, ec=...)
at /mnt/c/users/Thomas/Documents/Skole/3ING/TDAT3020/Øving 2/buggy-web-server/server_http.hpp:118
#13 0x00005555556870f7 in boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}>::operator()(boost::system::error_code const&, unsigned long) (this=0x7fffffffd6c8,
ec=..., bytes_transferred=74) at /usr/include/boost/asio/impl/write.hpp:663
#14 0x0000555555683a0f in boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >::operator()(boost::system::error_code const&, unsigned long, int) (this=0x7fffffffd6a0, ec=...,
bytes_transferred=74, start=0) at /usr/include/boost/asio/impl/write.hpp:345
#15 0x00005555556af46e in boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::const_buffers_1, boost::asio::detail::transfer_all_t, boost::asio::detail::write_streambuf_handler<std::allocator<char>, SimpleWeb::ServerBase<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> > >::Response::send_on_delete(std::function<void (boost::system::error_code const&)> const&)::{lambda(boost::system::error_code const&, unsigned long)#1}> >, boost::system::error_code, unsigned long>::operator()() (
this=0x7fffffffd6a0) at /usr/include/boost/asio/detail/bind_handler.hpp:127
#16 0x00005555556ae3b3 in boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::asio::detail::write_op<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, b---```
Edited by Thomas Bakken Moe