diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-10-28 14:18:18 +0200 |
|---|---|---|
| committer | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-10-28 14:35:29 +0200 |
| commit | 58e399400c4ef4b71472ab7c2c71c54a677a05a8 (patch) | |
| tree | e5405db640768f550e50420a1f13bef3404f5ac3 /accel-cmd/accel_cmd_test.c | |
| parent | b8a3c54aa34434312aa0053686ec37a133fb54e6 (diff) | |
| download | accel-ppp-58e399400c4ef4b71472ab7c2c71c54a677a05a8.tar.gz accel-ppp-58e399400c4ef4b71472ab7c2c71c54a677a05a8.zip | |
log: bound log lines and share target unpacking
A log line is flushed only when its text ends in a newline, so it can be
assembled from any number of log calls. Packet printers make one call per
attribute, so a single line could grow far beyond LOG_MAX_SIZE, while the
tcp, syslog and pgsql targets each copied the whole chunk list into a
fixed size buffer without checking its length.
Cap the accumulated line at LOG_MAX_SIZE in do_log(), keeping the
trailing newline so the line is still flushed, and replace the three
duplicated unpack loops with log_unpack_msg(), which never writes past
the size it is given. The syslog bound is needed on its own: a session
header plus a full length line does not fit its buffer.
Also skip empty formatted strings, which made do_log() read the byte
before its buffer.
When a single call is cut short by vsnprintf its newline is lost; restore
it when the format ends in one, so the line is closed instead of
swallowing the next one. The syslog and pgsql targets now strip the
trailing newline only when it is there, instead of dropping the last
character of a line cut to fit.
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
Diffstat (limited to 'accel-cmd/accel_cmd_test.c')
0 files changed, 0 insertions, 0 deletions
