From: Iker Pedrosa Date: Mon, 9 Sep 2024 08:36:17 +0000 (+0200) Subject: useradd: fix write_full() return value X-Git-Tag: 4.17.0-rc1~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8903b94c86c978e8abef623358fd3e4629c06967;p=thirdparty%2Fshadow.git 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 --- diff --git a/src/useradd.c b/src/useradd.c index 02c500d0c..d64fd892d 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"),