大型组名称对帐时崩溃

时间:2019-04-16 13:21:50

标签: c++ lotus-notes lotus-domino tivoli-identity-manager

我对C ++和Lotus笔记不了解很多。我有一段代码可以在日志中打印组名。

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

lnGrpName是LNstring。它工作正常,但是只要组名称长度超过2200,就会崩溃。

这是示例-假设组名是

  

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

是因为LNString或GetBuf()导致此问题吗?

AgentDebug方法在下面-

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 arguement
AdkDebug("%s",strBuff);


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

这是什么选择,因为我想在日志中打印组名。

2 个答案:

答案 0 :(得分:0)

我在想同样的事情吗?组名称只要2200字节还是字符?好。我不知道如何“解决”您的问题,但是假设您无法真正“解决”它,要“解决”它,我将截断字符串或​​将字符串添加为两个值。如果字符串长于2150,则将其分成两个字符串,并将它们都写入日志。只是一个想法。没有更多信息就做不到。

答案 1 :(得分:0)

与组名称相比,它看起来更像是组成员列表,但是好吧...

我对C ++和va_args的东西非常生锈,但是在我看来,您的tmp数组只能容纳2048 wchar_t,并且我假设您需要一个wchar_t作为空终止符,并且您有大约40个字符在您的格式字符串中。因此,当您传入长度为2200的字符串时,tmp就会溢出。如果我算的没错,那么长度超过2007的任何东西都会溢出tmp。