The problem is because only result of vsnprintf checked, but not cause of this result (e.g. errno).
One of case with this issue I've got and reproduced is hanging gsec on CentOS 6 which have bug in glibc (https://sourceware.org/bugzilla/show_bug.cgi?id=6530
For example simple reproduction for FB 3.x/4.x: shutdown server, create system audit file with service auditing and add it to firebird.conf:
enabled = true
log_filename = /tmp/log
log_services = true
log_service_query = false
Run gsec with locale which is not POSIX or C:
LANG=en_US.utf8 bin/gsec -user SYSDBA -password masterkey -add test -pw test
vprintf will get string like "-user SYSDBA -ADD \377TEST\377 -PW \377test\377" and will hang on it, because vsnprintf result always be -1 and errno always be 84.
All versions affected by infinity loop hang, because this part of code is same, but this particular case of course will hang only on 3.x/4.x.
1. Checking errno in vprintf and at least throw exception instead hang?
2. Cleanup service terminal symbols in TracePluginImpl::log_event_service_start before passing it to vprintf?