Skip to content

Commit

Permalink
Merge pull request #46 from grooverdan/MDEV-15655_fix
Browse files Browse the repository at this point in the history
MDEV-15655: abstract socket support - limit length
  • Loading branch information
9EOR9 committed Apr 22, 2018
2 parents db1028f + 6d92946 commit 698d361
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/pvio/pvio_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,10 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
{
#ifndef _WIN32
#ifdef HAVE_SYS_UN_H
size_t port_length;
struct sockaddr_un UNIXaddr;
if ((csock->socket = socket(AF_UNIX,SOCK_STREAM,0)) == INVALID_SOCKET ||
strlen(cinfo->unix_socket) >= (sizeof(UNIXaddr.sun_path)))
(port_length=strlen(cinfo->unix_socket)) >= (sizeof(UNIXaddr.sun_path)))
{
PVIO_SET_ERROR(cinfo->mysql, CR_SOCKET_CREATE_ERROR, unknown_sqlstate, 0, errno);
goto error;
Expand All @@ -763,7 +764,7 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
strcpy(UNIXaddr.sun_path, cinfo->unix_socket);
}
if (pvio_socket_connect_sync_or_async(pvio, (struct sockaddr *) &UNIXaddr,
sizeof(UNIXaddr)))
sizeof(UNIXaddr.sun_family) + port_length))
{
PVIO_SET_ERROR(cinfo->mysql, CR_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
ER(CR_CONNECTION_ERROR), cinfo->unix_socket, socket_errno);
Expand Down

0 comments on commit 698d361

Please sign in to comment.