Server crash due to invalid HTTP-version when trying to convert string to float
How to recreate crash
Sending a HTTP GET-request with an invalid HTTP-version such as a string, will cause the server to crash due to an invalid argument. The example below demonstrates this:
telnet localhost 8080
GET / HTTP/hei
Backtrace
terminate called after throwing an instance of 'std::invalid_argument'
what(): stof
Program received signal SIGABRT, Aborted.
__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 0x00007ffff705f801 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=0x7ffff7064fc0 <__GI_strtof>, __name=0x5555556b3036 "stof",
__str=0x5555558fccd0 "hei", __idx=0x0)
at /usr/include/c++/7/ext/string_conversions.h:83
#8 0x0000555555655a5a in std::__cxx11::stof (__str="hei", __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::strea---Type <return> to continue, or q <return> to quit---Quit