From 8903b94c86c978e8abef623358fd3e4629c06967 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 9 Sep 2024 10:36:17 +0200 Subject: [PATCH] useradd: fix write_full() return value write_full() returns -1 on error and useradd was checking another value. Closes: https://github.com/shadow-maint/shadow/issues/1072 Fixes: f45498a6c286 ("libmisc/write_full.c: Improve write_full()") Reported-by: Suggested-by: Reviewed-by: Alejandro Colomar Reviewed-by: Iker Pedrosa --- src/useradd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useradd.c b/src/useradd.c index 02c500d0..d64fd892 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -2042,7 +2042,7 @@ static void lastlog_reset (uid_t uid) return; } if ( (lseek (fd, offset_uid, SEEK_SET) != offset_uid) - || (write_full (fd, &ll, sizeof (ll)) != (ssize_t) sizeof (ll)) + || (write_full (fd, &ll, sizeof (ll)) == -1) || (fsync (fd) != 0)) { fprintf (stderr, _("%s: failed to reset the lastlog entry of UID %lu: %s\n"), -- 2.46.0