]> granicus.if.org Git - shadow/commitdiff
* src/lastlog.c, src/faillog.c: Fix underflows causing wrong entry
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Thu, 2 Jun 2011 20:26:30 +0000 (20:26 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Thu, 2 Jun 2011 20:26:30 +0000 (20:26 +0000)
to be displayed.

ChangeLog
src/faillog.c
src/lastlog.c

index b7a3290aae854e5c541a4b5ae219e040515b4371..d3a1a1b7f96ce72eb4dd0f3f6465067bd826330e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-02  Peter Vrabec  <pvrabec@redhat.com>
+
+       * src/lastlog.c, src/faillog.c: Fix underflows causing wrong entry
+       to be displayed.
+
 2011-06-02  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/xmalloc.c: Harmonize message.
index 8c10cab77e083daddb03b898893cabd37cad4a78..2742f2ee9d7f19accaa96edff6c9cdf6285e5f64 100644 (file)
@@ -118,8 +118,8 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
                return;
        }
 
-       offset = pw->pw_uid * sizeof (fl);
-       if (offset <= (statbuf.st_size - sizeof (fl))) {
+       offset = (off_t) pw->pw_uid * sizeof (fl);
+       if (offset + sizeof (fl) <= statbuf.st_size) {
                /* fseeko errors are not really relevant for us. */
                int err = fseeko (fail, offset, SEEK_SET);
                assert (0 == err);
@@ -218,8 +218,8 @@ static bool reset_one (uid_t uid)
        off_t offset;
        struct faillog fl;
 
-       offset = uid * sizeof (fl);
-       if (offset <= (statbuf.st_size - sizeof (fl))) {
+       offset = (off_t) uid * sizeof (fl);
+       if (offset + sizeof (fl) <= statbuf.st_size) {
                /* fseeko errors are not really relevant for us. */
                int err = fseeko (fail, offset, SEEK_SET);
                assert (0 == err);
@@ -333,7 +333,7 @@ static bool setmax_one (uid_t uid, int max)
        struct faillog fl;
 
        offset = (off_t) uid * sizeof (fl);
-       if (offset <= (statbuf.st_size - sizeof (fl))) {
+       if (offset + sizeof (fl) <= statbuf.st_size) {
                /* fseeko errors are not really relevant for us. */
                int err = fseeko (fail, offset, SEEK_SET);
                assert (0 == err);
@@ -450,7 +450,7 @@ static bool set_locktime_one (uid_t uid, long locktime)
        struct faillog fl;
 
        offset = (off_t) uid * sizeof (fl);
-       if (offset <= (statbuf.st_size - sizeof (fl))) {
+       if (offset + sizeof (fl) <= statbuf.st_size) {
                /* fseeko errors are not really relevant for us. */
                int err = fseeko (fail, offset, SEEK_SET);
                assert (0 == err);
index 43008c75c769868473929a97e643ae504c383a8f..83e3a5085f5b88a729708fa65254ceb5164d4785 100644 (file)
@@ -102,9 +102,8 @@ static void print_one (/*@null@*/const struct passwd *pw)
        }
 
 
-       offset = pw->pw_uid * sizeof (ll);
-
-       if (offset <= (statbuf.st_size - sizeof (ll))) {
+       offset = (off_t) pw->pw_uid * sizeof (ll);
+       if (offset + sizeof (ll) <= statbuf.st_size) {
                /* fseeko errors are not really relevant for us. */
                int err = fseeko (lastlogfile, offset, SEEK_SET);
                assert (0 == err);