From 684e29e18c946a7a46ade24d23bd264fcbd9b671 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Thu, 14 Aug 2025 14:12:29 +0200 Subject: [PATCH] fix(cfapi): check for valid ProcessInfo in cfApiFetchDataCallback This shouldn't happen, but just in case it does it'll avoid another crash. Signed-off-by: Jyrki Gadinger --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 00aa500d22..e61525c29e 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -130,8 +130,6 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const { qCDebug(lcCfApiWrapper) << "Fetch data callback called. File size:" << callbackInfo->FileSize.QuadPart; qCInfo(lcCfApiWrapper) << "Desktop client process id:" << QCoreApplication::applicationPid(); - qCInfo(lcCfApiWrapper) << "Fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; - qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); const auto sendTransferError = [=] { cfApiSendTransferInfo(callbackInfo->ConnectionKey, @@ -158,6 +156,15 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath)); const auto requestId = QString::number(callbackInfo->TransferKey.QuadPart, 16); + if (!callbackInfo->ProcessInfo) { + qCCritical(lcCfApiWrapper) << "Callback parameters did not contain required process info required for the implicit hydration check, aborting" << path << requestId; + sendTransferError(); + return; + } + + qCInfo(lcCfApiWrapper) << "Fetch data requested by process id:" << callbackInfo->ProcessInfo->ProcessId; + qCInfo(lcCfApiWrapper) << "Fetch data requested by application id:" << QString(QString::fromWCharArray(callbackInfo->ProcessInfo->ApplicationId)); + if (QCoreApplication::applicationPid() == callbackInfo->ProcessInfo->ProcessId) { qCCritical(lcCfApiWrapper) << "implicit hydration triggered by the client itself. Will lead to a deadlock. Cancel" << path << requestId; sendTransferError();