From d48dbe71dade959be82986e7e39cdabc29b55066 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 16 Dec 2021 01:52:37 +0100 Subject: [PATCH] Redundantly limit number of drag-and-drop formats As reported in #149, the DrumCore 3 plugin would segfault when trying to drag files from it. This happened because the plugin presumably underflows somewhere and then reports that it supports 4294967282 different drag-and-drop formats, even though yabridge asked for a maximum of 16. --- CHANGELOG.md | 4 ++++ src/wine-host/xdnd-proxy.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 805541e9..aeb0c914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ Versioning](https://semver.org/spec/v2.0.0.html). when the GUI changes. Yabridge now detects this, and removes the throttling we have in place to prevent certain other plugins from getting stuck in infinite loops. +- Fixed **DrumCore 3** crashing when trying to drag grooves from the plugin to + other applications. This happened because of an integer underflow in that + plugin, causing the number of reported drag-and-drop formats to be magnitudes + higher than yabridge's indicated maximum. - Fixed Wine version detection in the build configuration. ## [3.7.0] - 2021-11-21 diff --git a/src/wine-host/xdnd-proxy.cpp b/src/wine-host/xdnd-proxy.cpp index f205528d..6bacc7f0 100644 --- a/src/wine-host/xdnd-proxy.cpp +++ b/src/wine-host/xdnd-proxy.cpp @@ -790,6 +790,11 @@ void CALLBACK dnd_winevent_callback(HWINEVENTHOOK /*hWinEventHook*/, &num_formats); enumerator->Release(); + // NOTE: This DrumCore 3 plugin reports 4294967282 for `num_formats` which + // is uh a lot more than 16. So to prevent causing a segfault here we + // need to manually cap `num_formats` to 16. + num_formats = std::min(num_formats, static_cast(16)); + // NOTE: MeldaProduction plugins don't return any supported formats for some // reason, so we'll hardcode a HDROP if (num_formats == 0) {