Changeset 1154
- Timestamp:
- Sep 5, 2008, 10:37:19 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/dll/filldir.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/filldir.c
r1146 r1154 47 47 02 Aug 08 GKY Remove redundant strcpys from inner loop 48 48 23 Aug 08 GKY Free pszDisplayName when appropriate 49 01 Sep 08 GKY Updated FreeCnrItemData toprevent trap in strrchr if pci->pszFileName is NULL. 49 01 Sep 08 GKY Updated FreeCnrItemData to prevent trap in strrchr if pci->pszFileName is NULL. 50 05 Sep 08 SHL Correct FreeCnrItemData pszDisplayName pointer overlap check 50 51 51 52 ***********************************************************************/ … … 53 54 #include <stdlib.h> 54 55 #include <string.h> 56 #include <malloc.h> // _msize _heapchk 55 57 #include <ctype.h> 56 57 #if 0 // fixme to disable or to be configurable58 #include <malloc.h> // _heapchk59 #endif60 58 61 59 #define INCL_DOS … … 270 268 # ifdef FORTIFY 271 269 { 272 unsigned tid = GetTidForWindow(hwndCnr); 273 // char buf[256]; 274 if (tid == 1) 270 if (dcd->type != TREE_FRAME) 275 271 Fortify_ChangeScope(pci->pszFileName, -1); 276 else 272 else { 277 273 Fortify_SetOwner(pci->pszFileName, 1); 278 // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr));279 // Fortify_LabelPointer(pci->pszFmtFileSize, buf);274 Fortify_SetScope(pci->pszFileName, 2); 275 } 280 276 } 281 277 # endif … … 374 370 pci->pszLongName = xstrdup(value + (sizeof(USHORT) * 2), pszSrcFile, __LINE__); 375 371 # ifdef FORTIFY 376 { 377 unsigned tid = GetTidForWindow(hwndCnr); 378 // char buf[256]; 379 if (tid == 1) 380 Fortify_ChangeScope(pci->pszLongName, -1); 381 else 382 Fortify_SetOwner(pci->pszLongName, 1); 383 // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr)); 384 // Fortify_LabelPointer(pci->pszFmtFileSize, buf); 385 } 372 { 373 unsigned tid = GetTidForWindow(hwndCnr); 374 if (tid == 1) 375 Fortify_ChangeScope(pci->pszLongName, -1); 376 else 377 Fortify_SetOwner(pci->pszLongName, 1); 378 } 386 379 # endif 387 380 } … … 465 458 { 466 459 unsigned tid = GetTidForWindow(hwndCnr); 467 // char buf[256];468 460 if (tid == 1) 469 461 Fortify_ChangeScope(pci->pszFmtFileSize, -1); 470 462 else 471 463 Fortify_SetOwner(pci->pszFmtFileSize, 1); 472 // sprintf(buf, "Owner forced to %u", GetTidForWindow(hwndCnr));473 // Fortify_LabelPointer(pci->pszFmtFileSize, buf);474 464 } 475 465 # endif … … 529 519 } // FillInRecordFromFFB 530 520 531 ULONGLONG FillInRecordFromFSA(HWND hwndCnr, PCNRITEM pci, 521 ULONGLONG FillInRecordFromFSA(HWND hwndCnr, 522 PCNRITEM pci, 532 523 const PSZ pszFileName, 533 524 const PFILESTATUS4L pfsa4, 534 const BOOL partial, DIRCNRDATA * dcd) // Optional 525 const BOOL partial, 526 DIRCNRDATA *dcd) // Optional 535 527 { 536 528 HPOINTER hptr; … … 691 683 //comma format the file size for large file support 692 684 { 693 CHAR szBuf[30];685 CHAR szBuf[30]; 694 686 CommaFmtULL(szBuf, sizeof(szBuf), pfsa4->cbFile, ' '); 695 687 pci->pszFmtFileSize = xstrdup(szBuf, pszSrcFile, __LINE__); 688 # ifdef FORTIFY 689 { 690 if (dcd && dcd->type == TREE_FRAME) { 691 // Will be freed in TreeCnrWndProc WM_DESTROY 692 // Fortify_SetOwner(pci->pszFmtFileSize, 1); 693 Fortify_SetScope(pci->pszFmtFileSize, 2); 694 } 695 } 696 # endif 696 697 } 697 698 pci->date.day = pfsa4->fdateLastWrite.day; … … 1289 1290 pci->rc.hptrIcon = hptrDunno; 1290 1291 pci->pszFileName = xstrdup(szDrive, pszSrcFile, __LINE__); 1291 //strcpy(pci->pszFileName, szDrive); 1292 // strcpy(pci->pszFileName, szDrive); // 22 Jul 08 SHL No need to do this twice 1293 # ifdef FORTIFY 1294 // Will be freed by TreeCnrWndProc WM_DESTROY 1295 Fortify_SetScope(pci->pszFileName, 2); 1296 # endif 1292 1297 pci->pszDisplayName = pci->pszFileName; 1293 1298 pci->rc.pszIcon = pci->pszFileName; … … 1390 1395 char *p, *pp; 1391 1396 1392 p = pszTreeEnvVarList;1397 p = pszTreeEnvVarList; 1393 1398 while (*p == ';') 1394 1399 p++; … … 1642 1647 free(psz); 1643 1648 } 1649 1650 // Check double free 1644 1651 if (!pci->pszFileName) 1645 DbgMsg(pszSrcFile, __LINE__, "FreeCnrItemData pci->pszFileName is NULL"); 1646 if (pci->pszFileName && 1652 DbgMsg(pszSrcFile, __LINE__, "FreeCnrItemData pci->pszFileName already NULL"); 1653 1654 // Bypass free if pszDisplayName points into pszFileName buffer 1655 // 05 Sep 08 SHL Correct pointer overlap compare logic 1656 if (pci->pszDisplayName != pci->pszFileName && 1647 1657 pci->pszDisplayName && 1648 pci->pszDisplayName != NullStr &&1649 pci->pszDisplayName != pci->pszFileName &&1650 pci->pszDisplayName != strrchr(pci->pszFileName, '\\') && 1651 pci->pszDisplayName != strrchr(pci->pszFileName, ':') && 1652 pci->pszDisplayName != strrchr(pci->pszFileName, ':') + 1 &&1653 p ci->pszDisplayName != strrchr(pci->pszFileName, '\\') + 1) {1654 psz = pci->pszDisplayName;1655 //pci->pszDisplayName = NullStr;1656 pci->pszDisplayName = NULL; // for debug1657 free(psz);1658 }1658 pci->pszDisplayName != NullStr) { 1659 if (!pci->pszFileName || 1660 pci->pszDisplayName < pci->pszFileName || 1661 pci->pszDisplayName >= pci->pszFileName + _msize(pci->pszFileName)) 1662 { 1663 psz = pci->pszDisplayName; 1664 // pci->pszDisplayName = NullStr; 1665 pci->pszDisplayName = NULL; // for debug 1666 free(psz); 1667 } 1668 } 1659 1669 1660 1670 if (pci->pszFileName && pci->pszFileName != NullStr) {
Note:
See TracChangeset
for help on using the changeset viewer.
