436
436
* to log a message orginating from the syslogd itself.
439
logmsgInternal(int iErr, int pri, uchar *msg, int flags)
439
logmsgInternal(int iErr, int pri, const uchar *const msg, int flags)
441
441
uchar pszTag[33];
444
char *bufModMsg = NULL; /* buffer for modified message, should we need to modify */
448
/* we first do a path the remove control characters that may have accidently
449
* introduced (program error!). This costs performance, but we do not expect
450
* to be called very frequently in any case ;) -- rgerhards, 2013-12-19.
452
lenMsg = ustrlen(msg);
453
for(i = 0 ; i < lenMsg ; ++i) {
454
if(msg[i] < 0x20 || msg[i] == 0x7f) {
455
if(bufModMsg == NULL) {
456
CHKmalloc(bufModMsg = strdup((char*) msg));
445
461
CHKiRet(msgConstruct(&pMsg));
446
462
MsgSetInputName(pMsg, pInternalInputName);
447
MsgSetRawMsgWOSize(pMsg, (char*)msg);
463
MsgSetRawMsg(pMsg, (bufModMsg == NULL) ? (char*)msg : bufModMsg, lenMsg);
448
464
MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
449
465
MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
450
466
MsgSetRcvFromIP(pMsg, glbl.GetLocalHostIP());
475
491
if(((Debug == DEBUG_FULL || !doFork) && ourConf->globals.bErrMsgToStderr) || iConfigVerify) {
476
492
if(LOG_PRI(pri) == LOG_ERR)
477
fprintf(stderr, "rsyslogd: %s\n", msg);
493
fprintf(stderr, "rsyslogd: %s\n", (bufModMsg == NULL) ? (char*)msg : bufModMsg);
480
496
if(bHaveMainQueue == 0) { /* not yet in queued mode */