Changeset 1561


Ignore:
Timestamp:
May 29, 2011, 12:39:54 AM (14 years ago)
Author:
Gregg Young
Message:

Fixed trap on find dups when number of files exceeded the sizeof a USHORT (ticket 446). Increased vcollect stack size; comments.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/collect.c

    r1547 r1561  
    7373  23 Oct 10 GKY Add menu items for opening directory cnrs based on path of selected item
    7474                including the option to use walk directories to select path
     75  28 May 11 GKY Fixed trap caused by passing a nonexistant pci to FillInRecordFromFFB in
     76                UM_COLLECT because pci is limited to 65535 files. (nRecord is a USHORT)
    7577
    7678***********************************************************************/
     
    645647    if (dcd) {
    646648      LISTINFO *li = (LISTINFO *) mp1;
    647       INT x;
     649      INT x, y = 0;
    648650      FILEFINDBUF4L fb4;
    649651      HDIR hdir;
     
    654656      ULONGLONG ullTotalBytes;
    655657      CHAR fullname[CCHMAXPATH];
     658      INT makeShort = 0;
    656659
    657660      if (!hwndStatus) {
     
    663666          WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_COLLECTINGTEXT));
    664667      }
    665 
    666       for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ;        // Count
    667 
    668       if (ulMaxFiles) {
    669         pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
    670                          MPFROMLONG(EXTRA_RECORD_BYTES),
    671                          MPFROMLONG(ulMaxFiles));
    672         if (!pci) {
    673           Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD);
    674           break;
    675         }
    676         else {
    677           ITIMER_DESC itdSleep = { 0 };         // 06 Feb 08 SHL
    678           InitITimer(&itdSleep, 500);           // Sleep every 500 mSec
    679           pciFirst = pci;
    680           // 04 Jan 08 SHL fixme like comp.c if CM_ALLOCRECORD returns unexpected record count
    681           for (x = 0; li->list[x]; x++) {
    682             nm = 1;
    683             hdir = HDIR_CREATE;
    684             DosError(FERR_DISABLEHARDERR);
    685             if (FindCnrRecord(dcd->hwndCnr,
    686                               li->list[x],
    687                               NULL,
    688                               FALSE,
    689                               FALSE,
    690                               TRUE)) {
    691               pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
    692               if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
    693                 pci->rc.flRecordAttr &= ~CRA_FILTERED;
    694                 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
    695                            MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
    696               }
    697               pci = (PCNRITEM) pci->rc.preccNextRecord;
    698               if (pciP)
    699                 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
    700               else
    701                 pciFirst = pci;
    702             }
    703             else if (*li->list[x] &&
    704                 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
    705                                   fullname, sizeof(fullname)) &&
    706                 !IsRoot(fullname) &&
    707                 !xDosFindFirst(fullname,
    708                                &hdir,
    709                                FILE_NORMAL | FILE_DIRECTORY |
    710                                FILE_ARCHIVED | FILE_SYSTEM |
    711                                FILE_HIDDEN | FILE_READONLY,
    712                                &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
    713               DosFindClose(hdir);
    714               priority_normal();
    715                 *fb4.achName = 0;
    716                 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
    717                                                     pci,
    718                                                     fullname, &fb4, FALSE, dcd);
    719                 dcd->ullTotalBytes += ullTotalBytes;
    720                 pciP = pci;
    721                 pci = (PCNRITEM) pci->rc.preccNextRecord;
    722             }
    723             else {
    724               // Oops - fixme to complain?
    725               pciT = pci;
    726               pci = (PCNRITEM) pci->rc.preccNextRecord;
    727               if (pciP)
    728                 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
    729               else
    730                 pciFirst = pci;
    731               if (pciT)
    732                 FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
    733               ulMaxFiles--;             // Remember gone
    734             }
    735             SleepIfNeeded(&itdSleep, 1);        // 09 Feb 08 SHL
    736             // DosSleep(0); //26 Aug 07 GKY 1   // 09 Feb 08 SHL
    737           } // for
    738           if (ulMaxFiles) {
    739             // Some files OK
    740             memset(&ri, 0, sizeof(RECORDINSERT));
    741             ri.cb = sizeof(RECORDINSERT);
    742             ri.pRecordOrder = (PRECORDCORE) CMA_END;
    743             ri.pRecordParent = (PRECORDCORE) 0;
    744             ri.zOrder = (ULONG) CMA_TOP;
    745             ri.cRecordsInsert = ulMaxFiles;
    746             ri.fInvalidateRecord = TRUE;
    747             WinSendMsg(dcd->hwndCnr,
    748                        CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
    749             PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
    750           }
    751         }
    752       }
     668      while (li->list[y]) {
     669        for (ulMaxFiles = 0; li->list[ulMaxFiles + y] && ulMaxFiles < 65000; ulMaxFiles++) ;    // Count
     670
     671        if (ulMaxFiles) {
     672         
     673          pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
     674                           MPFROMLONG(EXTRA_RECORD_BYTES),
     675                           MPFROMLONG(ulMaxFiles));
     676          if (!pci) {
     677            Runtime_Error(pszSrcFile, __LINE__, PCSZ_CM_ALLOCRECORD);
     678            break;
     679          }
     680          else {
     681            ITIMER_DESC itdSleep = { 0 };               // 06 Feb 08 SHL
     682            InitITimer(&itdSleep, 500);         // Sleep every 500 mSec
     683            pciFirst = pci;
     684            // 04 Jan 08 SHL fixme like comp.c if CM_ALLOCRECORD returns unexpected record count
     685            for (x = y ; li->list[x]; x++) {
     686              nm = 1;
     687              hdir = HDIR_CREATE;
     688              DosError(FERR_DISABLEHARDERR);
     689              if (!makeShort &&
     690                  FindCnrRecord(dcd->hwndCnr, li->list[x], NULL, FALSE, FALSE, TRUE)) {
     691                pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
     692                if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
     693                  pci->rc.flRecordAttr &= ~CRA_FILTERED;
     694                  WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
     695                             MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
     696                }
     697                pci = (PCNRITEM) pci->rc.preccNextRecord;
     698                if (pciP)
     699                  pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
     700                else
     701                  pciFirst = pci;
     702              }
     703              else if (*li->list[x] &&
     704                  !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
     705                                    fullname, sizeof(fullname)) &&
     706                  !IsRoot(fullname) &&
     707                  !xDosFindFirst(fullname,
     708                                 &hdir,
     709                                 FILE_NORMAL | FILE_DIRECTORY |
     710                                 FILE_ARCHIVED | FILE_SYSTEM |
     711                                 FILE_HIDDEN | FILE_READONLY,
     712                                 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
     713                DosFindClose(hdir);
     714                priority_normal();
     715                *fb4.achName = 0;
     716                //DbgMsg(pszSrcFile, __LINE__, "hwndCnr %x pci %x fullname %s pci->rc.preccNextRecord %x x %x Max %x",
     717                //       dcd->hwndCnr, pci, fullname, pci->rc.preccNextRecord, x, ulMaxFiles);
     718                ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
     719                                                    pci,
     720                                                    fullname, &fb4, FALSE, dcd);
     721                dcd->ullTotalBytes += ullTotalBytes;
     722                pciP = pci;
     723                pci = (PCNRITEM) pci->rc.preccNextRecord;
     724              }
     725              else {
     726                // Oops - fixme to complain?
     727                pciT = pci;
     728                pci = (PCNRITEM) pci->rc.preccNextRecord;
     729                if (pciP)
     730                  pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
     731                else
     732                  pciFirst = pci;
     733                if (pciT)
     734                  FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
     735                ulMaxFiles--;           // Remember gone
     736              }
     737              SleepIfNeeded(&itdSleep, 1);      // 09 Feb 08 SHL
     738              // DosSleep(0); //26 Aug 07 GKY 1 // 09 Feb 08 SHL
     739              if (pciP->rc.preccNextRecord == 0) {
     740                y = x + 1;
     741                break;
     742              }
     743              y = x + 1;
     744            } // for
     745            if (ulMaxFiles) {
     746              //DbgMsg(pszSrcFile, __LINE__, "ri %x pciFirst %x x %x Max %x",
     747              //         ri, pciFirst, x, ulMaxFiles);
     748              // Some files OK
     749              memset(&ri, 0, sizeof(RECORDINSERT));
     750              ri.cb = sizeof(RECORDINSERT);
     751              ri.pRecordOrder = (PRECORDCORE) CMA_END;
     752              ri.pRecordParent = (PRECORDCORE) 0;
     753              ri.zOrder = (ULONG) CMA_TOP;
     754              ri.cRecordsInsert = ulMaxFiles;
     755              ri.fInvalidateRecord = TRUE;
     756              WinSendMsg(dcd->hwndCnr,
     757                         CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
     758              PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
     759              makeShort++;
     760              ulMaxFiles = 0;
     761            }
     762          }
     763        }
     764      } //While
    753765    }
    754766    if (dcd->flWindowAttr & CV_DETAIL)
     
    756768                        COLLECTOR_CNR,
    757769                        CM_INVALIDATERECORD,
    758                         MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
     770                        MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
    759771    return 0;
    760772
  • trunk/dll/treecnr.c

    r1555 r1561  
    773773      if (cnri.cRecords) {
    774774        sprintf(s, GetPString(IDS_NUMDRIVESTEXT), cnri.cRecords);
    775         if (pci && (INT) pci != -1 && pci->pszFileName && *pci->pszFileName) {
     775        if (pci && (INT) pci != -1 && *pci->pszFileName) { //fixme if can reproduce trap on *pci->psazFileName check invalid address
    776776          if (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
    777777                DRIVE_REMOVABLE) ||
  • trunk/vcollect.def

    r1531 r1561  
    77option description '@#The Netlabs FM/2 team:3.18.0#@##1## 05/30/2010 03:18:00      tresbopeep::EN:US:0:U:@@FM/2 Collector MiniApp Copyright (c) 1993, 1998 M. Kimes, Copyright (c) 2001, 2010 Steven Levine and Associates, Inc. All rights reserved'
    88
    9 option stack = 488416
     9option stack = 655360
Note: See TracChangeset for help on using the changeset viewer.