Bug fix in performance counter instance activation code

| 0 Comments

There's a bug in all releases of our performance counter library that may cause the creation of an instance with a name that has been previously used as an instance but that has been released to fail by connecting the new instance to the previously released instance data structure.

The bug is in PerformanceDataBlock.cpp, the else if around line 167 in AllocateObjectInstance() should be changed from:

      if (pInstance->NameLength == 0 && !pFirstFreeInstance)
      {
         pFirstFreeInstance = pInstance;
         firstFreeInstanceIndex = i;
      }
      else if (0 == memcmp(
         reinterpret_cast<byte *="">(pInstance)+ pInstance->NameOffset,
         unicodeInstanceName.c_str(), 
         unicodeInstanceNameLength))
      {
         allocationDisposition = ConnectedExisting;

to

      if (pInstance->NameLength == 0 && !pFirstFreeInstance)
      {
         pFirstFreeInstance = pInstance;
         firstFreeInstanceIndex = i;
      }
      else if (pInstance->NameLength == unicodeInstanceNameLength &&
               0 == memcmp(
                  reinterpret_cast<byte *="">(pInstance)+ pInstance->NameOffset, 
                  unicodeInstanceName.c_str(), 
                  unicodeInstanceNameLength))
      {
         allocationDisposition = ConnectedExisting;

Thanks to Steve and Ramzi at NetIQ for the bug report, analysis and bug fix.

This problem affects all released versions of the Performance counter library. The fix will be included in the 6.1 release of The Server Framework which currently has no scheduled release date. If you need have problems applying this fix then get in touch.

Leave a comment