]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Update Dmsg() to not modify the errno during a call
authorEric Bollengier <eric@baculasystems.com>
Wed, 26 Oct 2022 06:55:53 +0000 (08:55 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:00 +0000 (13:57 +0200)
bacula/src/lib/message.c

index ba9df681fc92238b109fc91a1284db35ebd39824..71e339975462ccd46fb22718200f752b543ce1ec 100644 (file)
@@ -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;
 }