[PATCH 1/3] msvcp: Implement the wchar version of _Open_dir.

Piotr Caban piotr.caban at gmail.com
Thu May 18 07:35:12 CDT 2017


Hi Stefan,

On 05/18/17 13:33, Stefan Dösinger wrote:
> +/* ??_Open_dir at sys@tr2 at std@@YAPAXPA_WPB_WAAHAAW4file_type at 123@@Z */
> +/* ??_Open_dir at sys@tr2 at std@@YAPEAXPEA_WPEB_WAEAHAEAW4file_type at 123@@Z */
> +void* __cdecl tr2_sys__Open_dir_wchar(wchar_t* target, wchar_t const* dest, int* err_code, enum file_type* type)
>  {
>      HANDLE handle;
> -    WIN32_FIND_DATAA data;
> -    char temppath[MAX_PATH];
> -
> -    TRACE("(%p %s %p %p)\n", target, debugstr_a(dest), err_code, type);
> -    if(strlen(dest) > MAX_PATH - 3) {
> +    WIN32_FIND_DATAW data;
> +    wchar_t temppath[MAX_PATH];
> +    static const wchar_t dot[] = {'.', 0};
> +    static const wchar_t dotdot[] = {'.', '.', 0};
> +    static const wchar_t asterisk[] = {'\\', '*', 0};
> +
> +    TRACE("(%p %s %p %p)\n", target, debugstr_w(dest), err_code, type);
> +    if(wcslen(dest) > MAX_PATH - 3) {
>          *err_code = ERROR_BAD_PATHNAME;
>          return NULL;
>      }
Could you please check if there really is such a length limit in wchar 
version of the function?
>
> +/* ?_Open_dir at sys@tr2 at std@@YAPAXAAY0BAE at DPBDAAHAAW4file_type@123@@Z */
> +/* ?_Open_dir at sys@tr2 at std@@YAPEAXAEAY0BAE at DPEBDAEAHAEAW4file_type@123@@Z */
> +void* __cdecl tr2_sys__Open_dir(char* target, char const* dest, int* err_code, enum file_type* type)
> +{
> +    void *handle;
> +    size_t len;
> +    wchar_t target_w[MAX_PATH];
> +    wchar_t *dest_w = NULL;
> +
> +    TRACE("(%p %s %p %p)\n", target, debugstr_a(dest), err_code, type);
> +
> +    if (dest)
> +    {
> +        len = strlen(dest) + 1;
> +        dest_w = malloc(sizeof(*dest_w) * len);
You don't need to allocate dest_w dynamically. Its length is limited to 
~MAX_PATH anyway.

Thanks,
Piotr



More information about the wine-devel mailing list