"Alex Villacís Lasso" a_villacis@palosanto.com wrote:
BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id ) {
- return DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
- BOOL16 ret = DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
- GetShortPathNameA(str, str, len);
- return ret;
}
BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id ) {
- return DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
- BOOL16 ret = DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
- GetShortPathNameA(str, str, len);
- return ret;
}
You are passing garbage to GetShortPathNameA in the case of failure.
Dmitry Timoshkov wrote:
"Alex Villacís Lasso" a_villacis@palosanto.com wrote:
BOOL16 WINAPI DlgDirSelectEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id ) {
- return DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
- BOOL16 ret = DlgDirSelectExA( WIN_Handle32(hwnd), str, len, id );
- GetShortPathNameA(str, str, len);
- return ret;
}
BOOL16 WINAPI DlgDirSelectComboBoxEx16( HWND16 hwnd, LPSTR str, INT16 len, INT16 id ) {
- return DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
- BOOL16 ret = DlgDirSelectComboBoxExA( WIN_Handle32(hwnd), str, len, id );
- GetShortPathNameA(str, str, len);
- return ret;
}
You are passing garbage to GetShortPathNameA in the case of failure.
And more importantly, the code in this patch is relying on GetShortPathNameA creating a copy of the long filename before copying it back.
Furthermore, the long file name might exceed the limit of len, whilst the short file name might not, prematurely truncating the short file name.