Changeset 837


Ignore:
Timestamp:
Sep 21, 2007, 9:17:59 PM (18 years ago)
Author:
Gregg Young
Message:

Fix for #144 crash when file names exceed max path; Initial xDosFindFirst/Next wrapper for performacne testing

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HISTORY

    r834 r837  
    333.08 (pending)
    44 o Rework filemask logic to match last extension and allow for string matching (Gregg)
     5 o Fix trap on search where file name length exceeds maxpath (Gregg)
    56
    673.07
  • trunk/dll/grep.c

    r813 r837  
    2626  26 Aug 07 GKY Improved performance of FillDups
    2727  26 Aug 07 GKY DosSleep(1) in loops changed to (0)
     28  21 Sep 07 GKY Fix trap on search that includes filenames that exceed maxpath
    2829
    2930***********************************************************************/
     
    411412  // step through all subdirectories
    412413  DosError(FERR_DISABLEHARDERR);
    413   if (!DosFindFirst(searchPath, &findHandle, (MUST_HAVE_DIRECTORY |
    414                                               FILE_ARCHIVED | FILE_SYSTEM |
    415                                               FILE_HIDDEN | FILE_READONLY),
    416                     &ffb, (ULONG) sizeof(ffb),
    417                     (PULONG) & ulFindCnt, FIL_QUERYEASIZE)) {
     414  if (!xDosFindFirst(searchPath, &findHandle, (MUST_HAVE_DIRECTORY |
     415                     FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY),
     416                     &ffb, (ULONG) sizeof(ffb),
     417                     (PULONG) & ulFindCnt, FIL_QUERYEASIZE)) {
    418418
    419419    // get rid of mask portion, save end-of-directory
     
    440440      }
    441441      ulFindCnt = 1;
    442     } while (!DosFindNext(findHandle,
    443                           &ffb,
    444                           sizeof(ffb), (PULONG) & ulFindCnt));
     442    } while (!xDosFindNext(findHandle,
     443                           &ffb,
     444                           sizeof(ffb), (PULONG) & ulFindCnt));
    445445    DosFindClose(findHandle);
    446446    priority_normal();
     
    487487  DosError(FERR_DISABLEHARDERR);
    488488  ulFindCnt = FilesToGet;
    489   rc = DosFindFirst(szFindPath,
    490                     &findHandle,
    491                     FILE_NORMAL | grep->attrFile | grep->antiattr,
    492                     pffbArray,
    493                     ulBufBytes,
    494                     &ulFindCnt,
    495                     FIL_QUERYEASIZE);
     489  rc = xDosFindFirst(szFindPath,
     490                     &findHandle,
     491                     FILE_NORMAL | grep->attrFile | grep->antiattr,
     492                     pffbArray,
     493                     ulBufBytes,
     494                     &ulFindCnt,
     495                     FIL_QUERYEASIZE);
    496496  if (!rc) {
    497497    do {
     
    503503          break;
    504504        if (*pffbFile->achName != '.' ||
    505             (pffbFile->achName[1] && pffbFile->achName[1] != '.')) {
    506           strcpy(p, pffbFile->achName); // build filename
     505            (pffbFile->achName[1] && pffbFile->achName[1] != '.')) {
     506          strcpy(p, pffbFile->achName); // build filename
     507          if (strlen(szFindPath) > 256){   //21 Sep GKY check for pathnames that exceed maxpath
     508            DosFindClose(findHandle);
     509            free(pffbArray);
     510            return 1;
     511          }
    507512          if (!grep->anyexcludes || !IsExcluded(szFindPath, fle, numfls)) {
    508513            if (!grep->finddupes)
     
    523528      DosSleep(0); //26 Aug 07 GKY 1
    524529      ulFindCnt = FilesToGet;
    525       rc = DosFindNext(findHandle, pffbArray, ulBufBytes, &ulFindCnt);
     530      rc = xDosFindNext(findHandle, pffbArray, ulBufBytes, &ulFindCnt);
    526531    } while (!rc);
    527532
Note: See TracChangeset for help on using the changeset viewer.