Am 04.01.2014 um 19:47 schrieb Alexander Barton alex@barton.de:
C99 states that vsnprintf() "returns the number of characters that would have been printed if the n were unlimited"; but according to the Linux manual page "glibc until 2.0.6 would return -1 when the output was truncated" -- so we have to handle both cases ...
src/ngircd/conn.c | 13 +++++++++++-- src/portab/portabtest.c | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-)
After quite a bit testing I fixed it slightly differently: the "portabtest" program of our test suite now only checks our own implementation that becomes used when the OS doesn't support vsnprintf() on its own; but when the OS version is used, and this function returns the wrong result, only a warning message is displayed (because it's not the fault of ngIRCd). This can happen with very old glibc and old libc 5 version on Linux, for example, as well as with quite a few older UNIX systems ...
ngIRCd uses this result in a single place, when checking if the client input exceeds the maximum allowed length for IRC commands. If not, the client should become disconnected. And this check can fail when vsnprintf() retuns the wrong result. But the input is always cut off correctly, so it isn't that problematic even on such old systems.
Thanks Alex