diff options
| author | Tom Yu <tlyu@mit.edu> | 2001-05-04 04:22:50 +0000 |
|---|---|---|
| committer | Tom Yu <tlyu@mit.edu> | 2001-05-04 04:22:50 +0000 |
| commit | 9530b1f60e4048438cf54718a5e7baf92a269e87 (patch) | |
| tree | e97d10f354c3ea57b96db94942584a83a96ba268 /src | |
| parent | 1d0c8300e47d13fa26f1016e4c695ae9342f168b (diff) | |
* dump-utmp.c: Fix some off-by-one errors. Handle cases where we
have utmpname() but not utmpname().
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13230 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
| -rw-r--r-- | src/util/pty/ChangeLog | 3 | ||||
| -rw-r--r-- | src/util/pty/dump-utmp.c | 25 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog index 42f3a69eb..41e6a3456 100644 --- a/src/util/pty/ChangeLog +++ b/src/util/pty/ChangeLog @@ -1,5 +1,8 @@ 2001-05-04 Tom Yu <tlyu@mit.edu> + * dump-utmp.c: Fix some off-by-one errors. Handle cases where we + have utmpname() but not utmpname(). + * pty-int.h: Fix typo; VHANG_first -> VHANG_FIRST. * open_slave.c (pty_open_slave): Add workaround for Tru64 v5.0, diff --git a/src/util/pty/dump-utmp.c b/src/util/pty/dump-utmp.c index 81bb49ce2..6847ac9bc 100644 --- a/src/util/pty/dump-utmp.c +++ b/src/util/pty/dump-utmp.c @@ -231,13 +231,8 @@ main(int argc, char **argv) perror(fn); exit(1); } - do { - nread = read(f, &u, recsize); - if (nread == -1) { - perror("read"); - exit(1); - } - if (nread && nread < recsize) { + while ((nread = read(f, &u, recsize)) > 0) { + if (nread < recsize) { fprintf(stderr, "short read"); close(f); exit(1); @@ -251,16 +246,25 @@ main(int argc, char **argv) } else { print_ut(all, &u.ut); } - } while (nread); + } + if (nread == -1) { + perror("read"); + exit(1); + } close(f); } else { if (is_utmpx) { -#if defined(UTMPX) && defined(UTN) +#ifdef UTMPX +#ifdef HAVE_UTMPXNAME utmpxname(fn); setutxent(); while ((utxp = getutxent()) != NULL) print_utx(all, utxp); #else + fprintf(stderr, "no utmpxname(); can't use getutxent()\n"); + exit(1); +#endif +#else abort(); #endif } else { @@ -270,7 +274,8 @@ main(int argc, char **argv) while ((utp = getutent()) != NULL) print_ut(all, utp); #else - abort(); + fprintf(stderr, "no utmpname(); can't use getutent()\n"); + exit(1); #endif } } |
