Corrected the length variable including length of timestampt string which doesn't include terminating null.
This commit is contained in:
parent
ab6469f2ae
commit
e57944ef44
@ -663,7 +663,8 @@ static int logmanager_write_log(
|
||||
flush);
|
||||
/**
|
||||
* Write timestamp with at most <timestamp_len> characters
|
||||
* to wp
|
||||
* to wp.
|
||||
* Returned timestamp_len doesn't include terminating null.
|
||||
*/
|
||||
timestamp_len = snprint_timestamp(wp, timestamp_len);
|
||||
/**
|
||||
@ -671,9 +672,9 @@ static int logmanager_write_log(
|
||||
* of the timestamp string.
|
||||
*/
|
||||
if (use_valist) {
|
||||
vsnprintf(wp+timestamp_len-1, safe_str_len, str, valist);
|
||||
vsnprintf(wp+timestamp_len, safe_str_len, str, valist);
|
||||
} else {
|
||||
snprintf(wp+timestamp_len-1, safe_str_len, str);
|
||||
snprintf(wp+timestamp_len, safe_str_len, str);
|
||||
}
|
||||
|
||||
/** write to syslog */
|
||||
@ -681,11 +682,11 @@ static int logmanager_write_log(
|
||||
{
|
||||
switch(id) {
|
||||
case LOGFILE_ERROR:
|
||||
syslog(LOG_ERR, wp+timestamp_len-1);
|
||||
syslog(LOG_ERR, wp+timestamp_len);
|
||||
break;
|
||||
|
||||
case LOGFILE_MESSAGE:
|
||||
syslog(LOG_NOTICE, wp+timestamp_len-1);
|
||||
syslog(LOG_NOTICE, wp+timestamp_len);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -694,10 +695,10 @@ static int logmanager_write_log(
|
||||
}
|
||||
|
||||
/** remove double line feed */
|
||||
if (wp[timestamp_len-1+str_len-2] == '\n') {
|
||||
wp[timestamp_len-1+str_len-2]=' ';
|
||||
if (wp[timestamp_len+str_len-2] == '\n') {
|
||||
wp[timestamp_len+str_len-2]=' ';
|
||||
}
|
||||
wp[timestamp_len-1+str_len-1]='\n';
|
||||
wp[timestamp_len+str_len-1]='\n';
|
||||
blockbuf_unregister(bb);
|
||||
|
||||
/**
|
||||
|
@ -1672,7 +1672,7 @@ static bool file_write_footer(
|
||||
if (header_buf3 == NULL) {
|
||||
goto return_succp;
|
||||
}
|
||||
tslen = snprint_timestamp(header_buf3, tslen-1);
|
||||
tslen = snprint_timestamp(header_buf3, tslen);
|
||||
header_buf4 = "\n--------------------------------------------"
|
||||
"---------------------------\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user