]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
useradd: fix write_full() return value
authorIker Pedrosa <ipedrosa@redhat.com>
Mon, 9 Sep 2024 08:36:17 +0000 (10:36 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 13 Sep 2024 07:44:51 +0000 (09:44 +0200)
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: <https://github.com/brown-midas>
Suggested-by: <https://github.com/brown-midas>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
src/useradd.c

index 02c500d0c28fbe0d5b18d1be4ec0bb33161e728b..d64fd892dd3f29cc8078d969b37d4de052a63130 100644 (file)
@@ -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"),