Search code examples
c++lotus-noteslotus-dominotivoli-identity-manager

Crashing on reconciliation of large group name


I don't have very much knowledge of C++ and Lotus notes. I have piece of code which prints the group name in log.

Util::AgentDebug("In Command::InitGroupMap(): Group Name = %s",lnGrpName.GetBuf());

lnGrpName is LNstring. it is working fine but whenever group name length is more than 2200, then it crashes.

here is the example - suppose group name is

asd.Storage.Implementation; task-mnncpohcpg01; task-paersc2hcpg01; azscotns02a; azscotns02b; ctshelns02a; ctshelns02b; flschons03a; flschons03b; iadubqns02a; iadubqns02b; mnncpoba0015; mnncpobrcd01; mnncpoisobrcd01; mnncpoisobrcd02; mnncpoisov7k01; mnncpolto01; mnncpolto01_1; mnncpolto01_imc; mnncpons03a; mnncpons03b; mnncpons900a_asd; mnncpons900b_asd; mnncpons900c; mnncpons900c_asd; mnncpons900d; mnncpons900d_asd; mnncpons900_asd; mnncpons900_sw1; mnncpons900_sw2; mnncposanc100; mnncposanc200; mnncposanr150; mnncposanr250; mnncposvc01; MNNCPOFL9KR01; MNNCPOFL9KR02; MNNCPONS900_sw1; MNNCPONS900_sw2; njmadins01a; njmadins01b; njros1ns05ta; njros1ns05tb; njwoodns05a; njwoodns05b; NJCTMVSP01; p2erscba0145; paersc1ns900a_asd; paersc1ns900b_asd; paersc1ns900c; paersc1ns900d; paersc1ns900_sw1; paersc1ns900_sw2; paersc2ns900a_asd; paersc2ns900b_asd; paersc2ns900c; paersc2ns900d; paersc2ns900_sw1; paersc2ns900_sw2; paersc2ocum01; paersc2opm01; paerscns05; paerscnsv501a; paerscnsv501b; PACTMVSP01; PAERSC1FL9KR01; PAERSC1FL9KR02; PAERSC1LABBRCD01; PAERSC1LABBRCD02; PAERSC1LABSVC01; PAERSC2FL9KR01; PAERSC2FL9KR02; PAERSC2FL9KR03; PAERSC2LABBRCD01; PAERSC2LABBRCD02; PAERSC2LABSVC01; txdallns02a; txdallns02b; MNNCPOBA0014; paerscsvc03; njros1svc01; njros1svc02; p1ehowld202; p1ehowld203; p2ehowld202; p2ehowld203; mnncpold202; mnncpold203; MNNCPONS805_asd; MNNCPONS805a_asd; MNNCPONS805b_asd; MNNCPONS805b_asd; paersc2ns805_asd; paersc2ns805a_asd; paersc2ns805b_asd; mnncpob15k01; paersc1g15k01; paersc2g15k01; paersc2sane103; paersc2sane203; P2ERSCBA0305; MNNCPOBA0277; P2ERSCAPL0005; MNNCPOAPL0016; p2erscba0147; mnncpoba0016; MNNCPOECSCN01; PAERSC2ECSCN01; PAERSC2FLAR900_1; P2ERSCAPL0006; njros1labcisc100; njros1labcisc200; p1erscba0402; paersc2ns700_sw1; paersc2ns700_sw2; paersc2ns700a_asd; paersc2ns700b_asd; paersc2ns700_asd; paersc1ns700_sw1; paersc1ns700_sw2; paersc1ns700a_asd; paersc1ns700b_asd; paersc1ns700_asd; mnncpons700_sw1; mnncpons700_sw1; mnncpons700_sw2; mnncpons700a_asd; mnncpons700b_asd; mnncpons700c_asd; mnncpons700d_asd; mnncpons700_asd; p2erscba0346; p2erscba0146; paersc1ns500; paersc1ns500a_asd; paersc1ns500b_asd; paersc2ns500; paersc2ns500a_asd; paersc2ns500b_asd

is this issue because of LNString or GetBuf()?

AgentDebug method is below -

void Util::AgentDebug( wchar_t * format , ... )
 {

wchar_t     tmp[2048];
va_list     args;
char        strBuff[4096];
int         j = 0;

va_start(args, format);
vswprintf_s(tmp, format, args);
va_end(args);

int cnt = wcstombs(strBuff, tmp, 4095);
if(cnt < 0)
{
    char *strInput = (char*)tmp;
    for( int i = 0; i < (wcslen(tmp) * 2); i++ )
    {
        if(strInput[i] != 0)
            strBuff[j++] = strInput[i];
    }
    strBuff[j] = '\0';
}
// AdkDebug (strBuff);
// Fix for IY98698 Certain Chinese character throws exception during recon (PMR10927999672)
// String to be logged is passed as second argument
AdkDebug("%s",strBuff);


 }// end of func AgentDebug()
  // end S15302

what is the alternative of this because i want to print group name in log.


Solution

  • That looks a lot more like a group membership list than a group name, but okay...

    I'm pretty rusty on my C++ and va_args stuff, but it looks to me like your tmp array can only hold 2048 wchar_t, and I assume that you need one wchar_t for the null terminator and you've got about 40 characters in your format string. So you're overflowing tmp when you pass in a string with length 2200. You'll overflow it with anything with a length that's longer than 2007 -- if I counted right.