From: Eric Bollengier Date: Wed, 26 Oct 2022 06:55:53 +0000 (+0200) Subject: Update Dmsg() to not modify the errno during a call X-Git-Tag: Beta-15.0.0~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef1d23084f6b0e88611d4af97922ac3a9fe52f16;p=thirdparty%2Fbacula.git Update Dmsg() to not modify the errno during a call --- diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index ba9df681f..71e339975 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -1175,10 +1175,18 @@ vd_msg(const char *file, int line, int64_t level, const char *fmt, va_list arg_p void d_msg(const char *file, int line, int64_t level, const char *fmt,...) { + /* Do not update the errno with a debug message that cannot be delivered + * correctly + */ + int errno_save = errno; + va_list arg_ptr; va_start(arg_ptr, fmt); vd_msg(file, line, level, fmt, arg_ptr); /* without tags */ va_end(arg_ptr); + + /* Revert the errno if the subroutines are in error */ + errno = errno_save; }