Changeset 1440


Ignore:
Timestamp:
Jul 13, 2009, 6:22:40 PM (16 years ago)
Author:
Steven Levine
Message:

Avoid trap in FillInRecordFromFSA if pszFSType NULL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/filldir.c

    r1439 r1440  
    7474  12 Jul 09 GKY Add szFSType to FillInRecordFromFSA use to bypass EA scan and size formatting
    7575                for tree container
     76  13 Jul 09 SHL Avoid trap in FillInRecordFromFSA if pszFSType NULL
    7677
    7778***********************************************************************/
     
    725726                              const PFILESTATUS4L pfsa4,
    726727                              const BOOL partial,
    727                               CHAR *szFSType,
     728                              CHAR *pszFSType,  // Optional
    728729                              DIRCNRDATA *dcd)  // Optional
    729730{
     
    738739  pci->pszFileName = xstrdup(pszFileName, pszSrcFile, __LINE__);
    739740
    740   if (pfsa4->cbList > 4L && dcd && *szFSType == 0)
     741  // 13 Jul 09 SHL fixme to know if fetch can be bypassed if pszFSType already filled
     742  // If FSType not supplied, assume don't need EAs either
     743  if (pfsa4->cbList > 4L && dcd && pszFSType)
    741744    FetchCommonEAs(pci);
    742745
     
    798801  else
    799802    p = pci->pszFileName;
    800   if (szFSType && (fShowFSTypeInTree || fShowDriveLabelInTree)) {
     803  if (pszFSType && (fShowFSTypeInTree || fShowDriveLabelInTree)) {
    801804    strcpy(szBuf, p);
    802805    strcat(szBuf, " [");
    803     strcat(szBuf, szFSType);
     806    strcat(szBuf, pszFSType);
    804807    strcat(szBuf, "]");
    805808    pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
     
    808811    pci->pszDisplayName = p;
    809812
    810   //comma format the file size for large file support
    811   if (*szFSType == 0) {
     813  // 13 Jul 09 SHL fixme to know why pszFSType check needed
     814  // comma format the file size for large file support
     815  if (!pszFSType || *pszFSType == 0) {
    812816    CHAR szBuf[30];
    813817    CommaFmtULL(szBuf, sizeof(szBuf), pfsa4->cbFile, ' ');
     
    958962    priority_normal();
    959963    pszFileSpec[strlen(pszFileSpec) - 1] = 0;     // Chop off wildcard
    960     //*pchEndPath = 0;                 
     964    //*pchEndPath = 0;
    961965    if (!rc) {
    962966      do {
     
    12351239  CHAR suggest[32];
    12361240  CHAR szDrive[] = " :\\";
    1237   CHAR szFSType[CCHMAXPATH]; 
     1241  CHAR szFSType[CCHMAXPATH];
    12381242  FILESTATUS4L fsa4;
    12391243  APIRET rc;
     
    12471251    driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS |
    12481252                      DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS |
    1249                       DRIVE_INCLUDEFILES | DRIVE_SLOW | DRIVE_NOSTATS |
    1250                       DRIVE_WRITEVERIFYOFF);
     1253                      DRIVE_INCLUDEFILES | DRIVE_SLOW | DRIVE_NOSTATS |
     1254                      DRIVE_WRITEVERIFYOFF);
    12511255  }
    12521256  memset(driveserial, -1, sizeof(driveserial));
     
    12681272              rc,
    12691273              HWND_DESKTOP,
    1270               pszSrcFile, __LINE__, PCSZ_FILLDIRQCURERRTEXT);
     1274              pszSrcFile, __LINE__, PCSZ_FILLDIRQCURERRTEXT);
    12711275    exit(0);
    12721276  }
     
    13011305      BOOL FSInfo = FALSE;
    13021306      struct {
    1303               ULONG serial;
    1304               CHAR volumelength;
    1305               CHAR volumelabel[CCHMAXPATH];
    1306              } volser;
     1307              ULONG serial;
     1308              CHAR volumelength;
     1309              CHAR volumelabel[CCHMAXPATH];
     1310             } volser;
    13071311
    13081312      *szDrive = (CHAR)x + 'A';         // Build path spec
     
    13201324          removable = CheckDrive(*szDrive, szFSType, &ulDriveType);
    13211325          driveserial[x] = -1;
    1322           if (removable != -1) {
    1323             DosError(FERR_DISABLEHARDERR);
    1324             if (!DosQueryFSInfo((ULONG) x + 1,
    1325                                 FSIL_VOLSER, &volser, sizeof(volser))) {
    1326               driveserial[x] = volser.serial;
    1327               FSInfo = TRUE;
    1328             }
     1326          if (removable != -1) {
     1327            DosError(FERR_DISABLEHARDERR);
     1328            if (!DosQueryFSInfo((ULONG) x + 1,
     1329                                FSIL_VOLSER, &volser, sizeof(volser))) {
     1330              driveserial[x] = volser.serial;
     1331              FSInfo = TRUE;
     1332            }
    13291333
    13301334          }
     
    13531357              strcmp(szFSType, NDFS32) &&
    13541358              strcmp(szFSType, RAMFS) &&
    1355               strcmp(szFSType, NTFS) &&
     1359              strcmp(szFSType, NTFS) &&
    13561360              strcmp(szFSType, HPFS386)) {
    13571361            driveflags[x] |= DRIVE_NOLONGNAMES;
     
    13691373            if (!(ulDriveType & DRIVE_NOLONGNAMES))
    13701374              driveflags[x] &= ~DRIVE_NOLONGNAMES;
    1371           }
    1372           if (!fVerifyOffChecked[x]) {
    1373             if (driveflags[x] & DRIVE_REMOVABLE)
    1374               driveflags[x] |= DRIVE_WRITEVERIFYOFF;
    1375             if (!(driveflags[x] & DRIVE_INVALID)) {
    1376               CHAR Key[80];
    1377 
    1378               sprintf(Key, "%c.VerifyOffChecked", (CHAR) (x + 'A'));
    1379               fVerifyOffChecked[x] = TRUE;
    1380               PrfWriteProfileData(fmprof, appname, Key, &fVerifyOffChecked[x], sizeof(BOOL));
    1381             }
    1382           }
    1383           if (strcmp(volser.volumelabel, NullStr) != 0 && FSInfo && fShowDriveLabelInTree)
    1384             strcpy(szFSType, volser.volumelabel);
     1375          }
     1376          if (!fVerifyOffChecked[x]) {
     1377            if (driveflags[x] & DRIVE_REMOVABLE)
     1378              driveflags[x] |= DRIVE_WRITEVERIFYOFF;
     1379            if (!(driveflags[x] & DRIVE_INVALID)) {
     1380              CHAR Key[80];
     1381
     1382              sprintf(Key, "%c.VerifyOffChecked", (CHAR) (x + 'A'));
     1383              fVerifyOffChecked[x] = TRUE;
     1384              PrfWriteProfileData(fmprof, appname, Key, &fVerifyOffChecked[x], sizeof(BOOL));
     1385            }
     1386          }
     1387          if (strcmp(volser.volumelabel, NullStr) != 0 && FSInfo && fShowDriveLabelInTree)
     1388            strcpy(szFSType, volser.volumelabel);
    13851389          pci->rc.flRecordAttr |= CRA_RECORDREADONLY;
    13861390          if ((ULONG)(toupper(*szDrive) - '@') == ulCurDriveNum)
     
    14061410                *suggest = '/';
    14071411                suggest[1] = 0;
    1408               }
    1409 
    1410               sprintf(suggest + strlen(suggest), "%c" , toupper(*szDrive));
    1411               pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1412               if (fShowFSTypeInTree || fShowDriveLabelInTree) {
    1413                 strcat(szDrive, " [");
    1414                 strcat(szDrive, szFSType);
    1415                 strcat(szDrive, "]");
    1416               }
     1412              }
     1413
     1414              sprintf(suggest + strlen(suggest), "%c" , toupper(*szDrive));
     1415              pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
     1416              if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     1417                strcat(szDrive, " [");
     1418                strcat(szDrive, szFSType);
     1419                strcat(szDrive, "]");
     1420              }
    14171421              pci->pszDisplayName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1418               szDrive[3] = 0;
     1422              szDrive[3] = 0;
    14191423              pci->rc.pszIcon = pci->pszDisplayName;
    14201424              pci->attrFile = FILE_DIRECTORY;
     
    14221426              driveserial[x] = -1;
    14231427            }
    1424             else
    1425               FillInRecordFromFSA(hwndCnr, pci, szDrive, &fsa4, TRUE, szFSType, NULL);
     1428            else
     1429              FillInRecordFromFSA(hwndCnr, pci, szDrive, &fsa4, TRUE, szFSType, NULL);
    14261430          }
    14271431          else {
    1428             // Removable volume
    1429             pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1430             if (fShowFSTypeInTree || fShowDriveLabelInTree) {
    1431               strcat(szDrive, " [");
    1432               strcat(szDrive, szFSType);
    1433               strcat(szDrive, "]");
    1434             }
     1432            // Removable volume
     1433            pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
     1434            if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     1435              strcat(szDrive, " [");
     1436              strcat(szDrive, szFSType);
     1437              strcat(szDrive, "]");
     1438            }
    14351439            pci->pszDisplayName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1436             szDrive[3] = 0;
     1440            szDrive[3] = 0;
    14371441            pci->rc.pszIcon = pci->pszDisplayName;
    14381442            pci->attrFile = FILE_DIRECTORY;
     
    14471451        else {
    14481452          *szFSType = 0;
    1449           pci->rc.hptrIcon = hptrDunno;
    1450           pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1451           if (fShowFSTypeInTree || fShowDriveLabelInTree) {
    1452             strcat(szDrive, " [?]");
    1453           }
     1453          pci->rc.hptrIcon = hptrDunno;
     1454          pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
     1455          if (fShowFSTypeInTree || fShowDriveLabelInTree) {
     1456            strcat(szDrive, " [?]");
     1457          }
    14541458          pci->pszDisplayName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1455           szDrive[3] = 0;
     1459          szDrive[3] = 0;
    14561460#         ifdef FORTIFY
    14571461          // Will be freed by TreeCnrWndProc WM_DESTROY
     
    14661470      else {
    14671471        // diskette drive (A or B)
    1468         pci->rc.hptrIcon = hptrFloppy;
    1469         pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1470         if (fShowFSTypeInTree || fShowDriveLabelInTree)
    1471           strcat(szDrive, "  [Floppy]");
     1472        pci->rc.hptrIcon = hptrFloppy;
     1473        pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__);
     1474        if (fShowFSTypeInTree || fShowDriveLabelInTree)
     1475          strcat(szDrive, "  [Floppy]");
    14721476        pci->pszDisplayName = xstrdup(szDrive, pszSrcFile, __LINE__);
    1473         szDrive[3] = 0;
     1477        szDrive[3] = 0;
    14741478        pci->rc.pszIcon = pci->pszDisplayName;
    14751479        pci->attrFile = FILE_DIRECTORY;
     
    15031507    {
    15041508      Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
    1505                 GetPString(IDS_CMINSERTERRTEXT));
     1509                GetPString(IDS_CMINSERTERRTEXT));
    15061510    }
    15071511  }
     
    16171621                                CM_QUERYRECORD,
    16181622                                MPVOID,
    1619                                 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
     1623                                MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
    16201624    StubbyScanCount ++;
    16211625    while (pci && (INT)pci != -1) {
Note: See TracChangeset for help on using the changeset viewer.