socket_client.cpp: prevent buffer overflow in creation of unix socket
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 10 Mar 2015 14:23:23 +0000 (15:23 +0100)
committerPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 10 Mar 2015 14:29:45 +0000 (15:29 +0100)
commit7d9c3eea7fd46abff305827c9e3f1fc7e5ab1e5d
tree9c0dcf8846d6e59ff1f063a2a0a048092d592573
parent44b4600fd51677e54dd167734ca9252b58237cda
socket_client.cpp: prevent buffer overflow in creation of unix socket

Path size for UNIX domain sockets is fixed at 108, however, the
method ``.unix_connect()`` of the socket client class accepts
STL strings of any length unchecked. Thus it’s trivial to provoke
a segfault:

    libt2n::socket_client_connection sc(std::string(42 * 42, '!'));

and ... bang!

A check of the client-supplied path value against the buffer size
of ``sockaddr_un.sun_path[]`` is added to prevent the issue.
src/socket_client.cpp