ClusterLabs / libqb

libqb is a library providing high performance logging, tracing, ipc, and poll.
http://clusterlabs.github.io/libqb/
GNU Lesser General Public License v2.1
165 stars 97 forks source link

log: fix potential overflow with long log messages #490

Closed chrissie-c closed 1 year ago

chrissie-c commented 1 year ago

qb_vsnprintf_serialize was called with 'max_size' as the limiting number for the length of the formatted log message. But the buffer also needs to contain the log header (given by 'actual_size'), so we now pass 'max_size - actual_size' as the maximum length of the formatted log message.

Also added error checks to the blacbkbox calls at the end of the test, as these now provide a proper test that the BB is functioning. Before they were masking failures.

chrissie-c commented 1 year ago

The ellipsis code has been in there for ages, but it needs to be enabled:

    rc = qb_log_ctl(t, QB_LOG_CONF_ELLIPSIS, QB_TRUE);

0ec02f9ac589e9e21e447f4406ec104ade01ef73

kgaillot commented 1 year ago

The ellipsis code has been in there for ages, but it needs to be enabled:

    rc = qb_log_ctl(t, QB_LOG_CONF_ELLIPSIS, QB_TRUE);

0ec02f9

log_blackbox.c doesn't use qb_log_target_format() (I'm not familiar enough with the code to know why not), so the ellipsis code isn't hit