From 578a9475ecf7b8c529bb7edb86885987aa77642d Mon Sep 17 00:00:00 2001 From: Cyp <48363+Cyp@users.noreply.github.com> Date: Fri, 22 Nov 2019 14:26:00 +0100 Subject: [PATCH] Fix invalid read in RemotePlugin::RemotePlugin() on opening the ZynAddSubFx GUI. (#5299) Calling .toUtf8().constData() returns a pointer which is invalid at the end of the statement. --- src/core/RemotePlugin.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index d82bc61af..f816b7529 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -101,14 +101,14 @@ RemotePlugin::RemotePlugin() : m_socketFile = QDir::tempPath() + QDir::separator() + QUuid::createUuid().toString(); - const char * path = m_socketFile.toUtf8().constData(); - size_t length = strlen( path ); + auto path = m_socketFile.toUtf8(); + size_t length = path.length(); if ( length >= sizeof sa.sun_path ) { length = sizeof sa.sun_path - 1; qWarning( "Socket path too long." ); } - memcpy( sa.sun_path, path, length ); + memcpy(sa.sun_path, path.constData(), length ); sa.sun_path[length] = '\0'; m_server = socket( PF_LOCAL, SOCK_STREAM, 0 ); @@ -116,7 +116,7 @@ RemotePlugin::RemotePlugin() : { qWarning( "Unable to start the server." ); } - remove( path ); + remove(path.constData()); int ret = bind( m_server, (struct sockaddr *) &sa, sizeof sa ); if ( ret == -1 || listen( m_server, 1 ) == -1 ) {