Re: buffer check in comdlg
Aric Stewart wrote:
if(fodInfos->unicode) { LPOPENFILENAMEW ofn = fodInfos->ofnInfos; - strcpyW( ofn->lpstrFile, lpstrPathSpec); - memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) ); + if (nSizePath+sizeUsed > ofn->nMaxFile) + { + *((WORD*)ofn->lpstrFile)=nSizePath+sizeUsed; + FILEDLG95_Clean(hwnd); + EndDialog(hwnd,FALSE); + COMDLG32_SetCommDlgExtendedError(FNERR_BUFFERTOOSMALL); + return FALSE; + } + else + { + strcpyW( ofn->lpstrFile, lpstrPathSpec); + memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) ); + } }
This formatting doesn't look at all consistent, either with itself or the other code there. -- Rob Shearman
Drat bitten by formatting again. And i thought i checked but i realized i checked and then reedited the file and my setting returned to default. Should i redo the formatting and resubmit? -aric Robert Shearman wrote:
Aric Stewart wrote:
if(fodInfos->unicode) { LPOPENFILENAMEW ofn = fodInfos->ofnInfos; - strcpyW( ofn->lpstrFile, lpstrPathSpec); - memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) ); + if (nSizePath+sizeUsed > ofn->nMaxFile) + { + *((WORD*)ofn->lpstrFile)=nSizePath+sizeUsed; + FILEDLG95_Clean(hwnd); + EndDialog(hwnd,FALSE); + COMDLG32_SetCommDlgExtendedError(FNERR_BUFFERTOOSMALL); + return FALSE; + } + else + { + strcpyW( ofn->lpstrFile, lpstrPathSpec); + memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) ); + } }
This formatting doesn't look at all consistent, either with itself or the other code there.
participants (2)
-
Aric Stewart -
Robert Shearman