x11drv: XDND: Fix file drop to properly support file:/// URIs(debugging problem)

Dmitry Timoshkov dmitry at codeweavers.com
Wed Mar 21 23:02:44 CDT 2007


Maciej Katafiasz <ml at mathrick.org> wrote:

> +     if(!strncasecmp(p, "://localhost/", 13))
> +     {
> +       i = 12;
> +     } else if (!strncasecmp(p, ":///", 4))
> +     {
> +       i = 3;
> +     } else
> +     {
> +       TRACE("Not a valid file: URI: %s\n", (char*)data);
> +       return count;
> +     }

Please use the same indentation style as the existing does, i.e. 4 spaces,
not 2.

> +    pathlen = MultiByteToWideChar(CP_UNIXCP, 0, filename, len, NULL, 0);
> +
> +    wfn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathlen);

You allocate not enough space for a wide char string.

> +    TRACE("Convert to WCHAR: filename: %s, len: %d\n", debugstr_a(filename), pathlen);
> +    pathlen = MultiByteToWideChar(CP_UNIXCP, 0, filename, len, wfn, pathlen);
> +    if(GetLastError())
> +    {
> +      TRACE("Can't convert to WCHAR: %d\n", GetLastError());
> +      goto clean_wfn;
> +    }

This is not an appropriate way of testing for an API failure.

> +    TRACE("WCHAR filename: %s\n", debugstr_w(wfn));
> +    wpath = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, pathlen * sizeof(WCHAR));

Memory space calculations and allocations don't look right all over the place.

> -        strcpy(((char*)lpDrop)+lpDrop->pFiles, path);
> +        memcpy(((char*)lpDrop)+lpDrop->pFiles, (char*)wpath, fullpathlen * sizeof(WCHAR));

Use lstrcpyW here instead of memcpy.

-- 
Dmitry.



More information about the wine-devel mailing list