Changeset 087a3c9 in nscp for trunk/include/NSCHelper.cpp


Ignore:
Timestamp:
02/19/08 19:10:56 (5 years ago)
Author:
Michael Medin <michael@…>
Children:
6922706
Parents:
34f5502
Message:

+ Fixed a buffer overflow in the NRPE socket handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/NSCHelper.cpp

    rbe0202f r087a3c9  
    2424#include <msvc_wrappers.h> 
    2525#include <config.h> 
     26#include <strEx.h> 
    2627 
    2728#ifdef DEBUG 
     
    6970int NSCHelper::wrapReturnString(TCHAR *buffer, unsigned int bufLen, std::wstring str, int defaultReturnCode ) { 
    7071  // @todo deprecate this 
    71   if (str.length() >= bufLen) 
     72  if (str.length() >= bufLen) { 
     73    std::wstring sstr = str.substr(0, min(10, str.length())); 
     74    NSC_DEBUG_MSG_STD(_T("String (") + strEx::itos(str.length()) + _T(") to long to fit inside buffer(") + strEx::itos(bufLen) + _T(") : ") + sstr); 
    7275    return NSCAPI::isInvalidBufferLen; 
     76  } 
    7377  wcsncpy_s(buffer, bufLen, str.c_str(), bufLen); 
    7478  return defaultReturnCode; 
     
    110114  else if (returnCode == NSCAPI::returnWARN) 
    111115    return _T("WARNING"); 
     116  else if (returnCode == NSCAPI::returnUNKNOWN) 
     117    return _T("WARNING"); 
    112118  else 
    113     return _T("UNKNOWN"); 
     119    return _T("BAD_CODE"); 
    114120} 
    115121 
Note: See TracChangeset for help on using the changeset viewer.