Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 0.8.1, 0.8.2, and 0.8.3

merge with Adrian

Changeset aa627f38b978

Parents 42d97738670a

Parents 2fc596e128ab

by Steve Borho

Changes to one file · Browse files at aa627f38b978 Showing diff from parent 42d97738670a 2fc596e128ab Diff from another changeset...

 
453
454
455
456
457
458
459
460
461
462
463
464
465
 
 
 
 
 
466
467
468
469
470
471
 
 
472
473
474
 
 
 
 
 
 
475
476
477
478
479
480
481
 
 
 
 
482
483
484
485
486
487
488
489
490
491
 
 
 
492
493
494
495
496
497
498
499
500
 
501
502
503
504
 
 
505
506
507
 
453
454
455
 
 
 
 
 
456
457
458
459
 
460
461
462
463
464
465
466
467
468
469
 
470
471
472
473
 
474
475
476
477
478
479
480
481
482
483
484
 
485
486
487
488
489
490
 
 
 
 
 
491
492
493
 
494
495
496
497
 
 
 
 
 
498
499
 
500
501
502
 
 
503
504
505
506
507
@@ -453,55 +453,55 @@
 {   const char *psz = "";   - TDEBUG_TRACE( - "CShellExt::GetCommandString: idCmd = " << idCmd - << ", uFlags = " << uFlags - ); -   MenuIdCmdMap::iterator iter = MenuIdMap.find(static_cast<UINT>(idCmd));   if (iter != MenuIdMap.end())   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: name = " << iter->second.name); + "CShellExt::GetCommandString: idCmd = " << idCmd + << ", uFlags = " << uFlags + << ", name = " << iter->second.name + << ", helpText = " << iter->second.helpText + );   psz = iter->second.helpText.c_str();   }   else   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: can't find idCmd " << idCmd); + "CShellExt::GetCommandString: idCmd = " << idCmd + << ", uFlags = " << uFlags << " -> not found");   }   - bool copied = false; + if (cchMax < 1) + { + TDEBUG_TRACE("CShellExt::GetCommandString: cchMax = " << cchMax); + return NOERROR; + } +   size_t size = 0;     if (uFlags & GCS_UNICODE)   {   wchar_t* const dest = reinterpret_cast<wchar_t*>(pszName); - *dest = 0;   const wchar_t* const src = _WCSTR(psz); + + wcsncpy(dest, src, cchMax-1); + *(dest + cchMax-1) = 0; +   size = wcslen(src); - if (size < cchMax) - { - wcscpy(dest, src); - copied = true; - }   }   else   { - *pszName = 0; + strncpy(pszName, psz, cchMax-1); + *(pszName + cchMax-1) = 0; +   size = strlen(psz); - if (size < cchMax) - { - strcpy(pszName, psz); - copied = true; - }   }   - if (!copied) + if (size > cchMax-1)   {   TDEBUG_TRACE( - "CShellExt::GetCommandString: error: source string length (" - << size << ") exceeds target buffer size (" << cchMax << ")"); + "CShellExt::GetCommandString: string was truncated: size = " + << size << ", cchMax = " << cchMax);   }     return NOERROR;