[PATCH] check length in path canonicalize

Dmitry Timoshkov dmitry at codeweavers.com
Sun Dec 3 06:06:13 CST 2006


"Marcus Meissner" <marcus at jet.franken.de> wrote:

> -    MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
> +    INT ret;
> +
> +    ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,NULL,0);
> +    if (ret > MAX_PATH) {
> + FIXME("Too long path!\n");
> + return FALSE;
> +    }
> +    ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,sizeof(szPath)/sizeof(WCHAR));

It should be sufficient to check return value of MultiByteToWideChar
to detect an overflow, there is no need to call MultiByteToWideChar
twice for that.

-- 
Dmitry.



More information about the wine-devel mailing list