https://bugs.kde.org/show_bug.cgi?id=482137

Marcel Hasler <mahas...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mahas...@gmail.com

--- Comment #6 from Marcel Hasler <mahas...@gmail.com> ---
(In reply to Ninjoe from comment #5)
> As of 24.05, folder sharing still doesn't work.

This is a bug in RdpSession::start().

Actually the code is wrong in a few ways:
1. freerdp_client_add_device_channel() expects the number of strings passed,
which should be >= 2 for the "drive" channel. Passing 1 will cause the function
to abort (see
https://github.com/FreeRDP/FreeRDP/blob/5b14b7cbdd36414f1838047f21502654bd32ebb1/client/common/cmdline.c#L539)
2. strdup is used to copy the string "drive", but the pointer returned is never
freed, causing a memory leak (see
https://en.cppreference.com/w/c/experimental/dynamic/strdup)
3. The pointer returned by m_preferences->shareMedia().toLocal8Bit().data() is
no longer valid by the time it's passed to freerdp_client_add_device_channel,
since it references a temporary object that no longer exists at this point

I would suggest the following implementation which I have just tested and that
works for me:

    if (!m_preferences->shareMedia().isEmpty()) {
        QByteArray name = "drive";
        QByteArray value = m_preferences->shareMedia().toLocal8Bit();

        char *params[2] = { name.data(), value.data() };
        freerdp_client_add_device_channel(settings, 2, params);
    }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to