From: <mie...@us...> - 2013-10-26 23:49:51
|
Revision: 9487 http://sourceforge.net/p/oorexx/code-0/9487 Author: miesfeld Date: 2013-10-26 23:49:48 +0000 (Sat, 26 Oct 2013) Log Message: ----------- Bugs: #1203 ooRexx 4.1.3 64-bit on Windows 7 Home Premium SysFileTree attribute handling errors. Modified Paths: -------------- main/branches/4.1/trunk/extensions/rexxutil/platform/windows/rexxutil.cpp Modified: main/branches/4.1/trunk/extensions/rexxutil/platform/windows/rexxutil.cpp =================================================================== --- main/branches/4.1/trunk/extensions/rexxutil/platform/windows/rexxutil.cpp 2013-10-26 23:49:12 UTC (rev 9486) +++ main/branches/4.1/trunk/extensions/rexxutil/platform/windows/rexxutil.cpp 2013-10-26 23:49:48 UTC (rev 9487) @@ -2092,34 +2092,23 @@ { SYSTEMTIME systime; FILETIME ftLocal; - uint32_t changedAttr; // New file attributes. - // The file attributes need to be changed before we format the found file - // line. - - changedAttr = newAttr(newMask, wfd->dwFileAttributes); - if ( changedAttr != wfd->dwFileAttributes ) - { - // try to set the attributes, but if it fails, just use the exsiting. - if ( ! setAttr(treeData->foundFile, changedAttr & ~FILE_ATTRIBUTE_DIRECTORY) ) - { - changedAttr = wfd->dwFileAttributes; - } - } - char *dFoundFile = treeData->foundFile; size_t nFoundFile = sizeof(treeData->foundFile); - int len = _snprintf(treeData->foundFile, sizeof(treeData->foundFile), "%s%s", path, wfd->cFileName); + int len = _snprintf(dFoundFile, nFoundFile, "%s%s", path, wfd->cFileName); if ( len < 0 || len == nFoundFile ) { - nFoundFile = strlen(path) + strlen(wfd->cFileName); + nFoundFile = strlen(path) + strlen(wfd->cFileName) + 1; dFoundFile = (char *)LocalAlloc(LPTR, nFoundFile); if ( dFoundFile == NULL ) { outOfMemoryException(c->threadContext); return false; } + + // Buffer is sure to be big enough now, we we don't check the return. + _snprintf(dFoundFile, nFoundFile, "%s%s", path, wfd->cFileName); } if ( options & NAME_ONLY ) @@ -2138,6 +2127,19 @@ return true; } + // The file attributes need to be changed before we format the found file + // line. + + uint32_t changedAttr = newAttr(newMask, wfd->dwFileAttributes); + if ( changedAttr != wfd->dwFileAttributes ) + { + // try to set the attributes, but if it fails, just use the exsiting. + if ( ! setAttr(treeData->foundFile, changedAttr & ~FILE_ATTRIBUTE_DIRECTORY) ) + { + changedAttr = wfd->dwFileAttributes; + } + } + // Convert UTC to local file time, and then to system format. FileTimeToLocalFileTime(&wfd->ftLastWriteTime, &ftLocal); FileTimeToSystemTime(&ftLocal, &systime); @@ -2211,6 +2213,8 @@ } return false; } + // Buffer is sure to be big enough now so we don't check return. + _snprintf(dFoundFileLine, nFoundFileLine, "%s%s%s", treeData->fileTime, treeData->fileAttr, dFoundFile); } // Place found file line in the stem. @@ -2308,6 +2312,8 @@ result = false; goto done_out; } + // buffer is sure to be big enough now, so we don't check the return. + _snprintf(dTmpFileName, nTmpFileName, "%s%s", path, treeData->dFNameSpec); } fHandle = FindFirstFile(dTmpFileName, &wfd); @@ -2373,6 +2379,9 @@ result = false; goto done_out; } + // buffer is sure to be big enough now, so we don't check the + // return. + _snprintf(dTmpFileName, nTmpFileName, "%s%s\\", path, wfd.cFileName); } // Search the next level. |