summaryrefslogtreecommitdiff
path: root/accel-pppd/logs/log_pgsql.c
AgeCommit message (Collapse)Author
4 dayslog: bound log lines and share target unpackingDenys Fedoryshchenko
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>
2026-08-12log_pgsql: deprecate the module and rename its build flagDenys Fedoryshchenko
The PostgreSQL logging target sees little use and has been a source of memory safety bugs. Mark it as deprecated and scheduled for removal, but give anyone depending on it a chance to object first. To make sure this is not missed, the LOG_PGSQL build flag now fails the build with an explanation, building the module requires the renamed LOG_PGSQL_DEPRECATED flag, cmake prints a warning when it is used, and the module logs a deprecation warning on startup.
2026-08-11utils: centralize min macroDenys Fedoryshchenko
Several userspace translation units carry identical local min() definitions. Move the guarded definition to utils.h and include it from each user so there is one implementation to maintain. The Linux min() macro lives in kernel-internal headers and is not part of the userspace UAPI. Clang/LLVM does not provide a compatible min macro either: C++ code uses std::min and Clang's similarly named operations use explicit builtin names. The userspace <sys/param.h> interface, where available, exposes uppercase MIN instead. Keep the #ifndef guard to preserve the behavior of the existing local definitions and avoid redefining a lowercase min macro supplied by an unrelated third-party header.
2026-08-11log_pgsql: bound username and sessionid in log headerDenys Fedoryshchenko
set_hdr() copied the session username and sessionid into the message header chunk with strcpy(). That chunk comes from chunk_pool and holds only LOG_CHUNK_SIZE + 1 bytes, while the username is peer supplied and may be up to 255 bytes long (PAP), so a long username overflowed the chunk and corrupted the heap when log-pgsql was enabled. Use snprintf() to truncate both fields to the space left in the chunk.
2014-11-22remove trailing whitespacesDmitry Kozlov
2014-06-16log_pgsql: update calls to new triton interfaceDmitry Kozlov
2014-06-03get out of SPINLOCK_INITIALIZER as it is not cross-platform compatibleDmitry Kozlov
2013-08-06fixed compiling log_pgsqlDmitry Kozlov
2011-05-30rewrited initialization procedure (fix gcc-4.6 builds)Kozlov Dmitry
2011-01-05rename accel-pptp to accel-pppDmitry Kozlov