]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
random-seed: fix wrong error variable in log_error_errno()
authordongshengyuan <545258830@qq.com>
Mon, 15 Jun 2026 07:43:51 +0000 (15:43 +0800)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 15 Jun 2026 12:16:28 +0000 (14:16 +0200)
At line 285, ftruncate() failure was logged using 'r' which is 0
from the preceding successful loop_write() call. log_error_errno(0, ...)
triggers an assertion crash in developer builds (ASSERT_NON_ZERO) and
silently returns success in release builds, swallowing the ftruncate error.

Replace with errno which is set by ftruncate() on failure.

Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
Co-developed-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
src/random-seed/random-seed-tool.c

index 514176ef5d8ea2518cb55a6ca51b9134155d23d5..289291761f0297b3de95c7138acc8b110320136f 100644 (file)
@@ -282,7 +282,7 @@ static int save_seed_file(
                 return log_error_errno(r, "Failed to write new random seed file: %m");
 
         if (ftruncate(seed_fd, k) < 0)
-                return log_error_errno(r, "Failed to truncate random seed file: %m");
+                return log_error_errno(errno, "Failed to truncate random seed file: %m");
 
         r = fsync_full(seed_fd);
         if (r < 0)