summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/pty/ChangeLog7
-rw-r--r--src/util/pty/dump-utmp.c12
2 files changed, 14 insertions, 5 deletions
diff --git a/src/util/pty/ChangeLog b/src/util/pty/ChangeLog
index d598f954a4..39797d41ef 100644
--- a/src/util/pty/ChangeLog
+++ b/src/util/pty/ChangeLog
@@ -3,6 +3,13 @@
* update_utmp.c (pty_update_utmp): Don't copy host if it's a null
pointer.
+ * dump-utmp.c (print_ut): Use size of ut_name field, not ut_user,
+ which may not exist, for width when printing ut_name field value.
+ Specify width when printing hostname, it may be unterminated.
+ (main): Move utp and utxp declarations closer to their usages, and
+ make both conditionalized so they're not declared if they're not
+ used.
+
2001-06-21 Ezra Peisach <epeisach@mit.edu>
* libpty.h: Change variable line in prototype to tty_line to
diff --git a/src/util/pty/dump-utmp.c b/src/util/pty/dump-utmp.c
index 6847ac9bce..c72f5b5bc5 100644
--- a/src/util/pty/dump-utmp.c
+++ b/src/util/pty/dump-utmp.c
@@ -89,7 +89,11 @@ print_ut(int all, const struct utmp *u)
return;
#endif
+#ifdef HAVE_STRUCT_UTMP_UT_USER
lu = sizeof(u->ut_user);
+#else
+ lu = sizeof(u->ut_name);
+#endif
ll = sizeof(u->ut_line);
printf("%-*.*s:", lu, lu, u->ut_name);
printf("%-*.*s:", ll, ll, u->ut_line);
@@ -113,7 +117,7 @@ print_ut(int all, const struct utmp *u)
printf(" %s", ctime(&u->ut_time) + 4);
#ifdef HAVE_STRUCT_UTMP_UT_HOST
if (u->ut_host[0])
- printf(" %s\n", u->ut_host);
+ printf(" %.*s\n", (int) sizeof(u->ut_host), u->ut_host);
#endif
return;
@@ -194,10 +198,6 @@ main(int argc, char **argv)
struct utmpx utx;
#endif
} u;
- struct utmp *utp;
-#ifdef UTMPX
- struct utmpx *utxp;
-#endif
all = is_utmpx = do_getut = 0;
recsize = sizeof(struct utmp);
@@ -256,6 +256,7 @@ main(int argc, char **argv)
if (is_utmpx) {
#ifdef UTMPX
#ifdef HAVE_UTMPXNAME
+ struct utmpx *utxp;
utmpxname(fn);
setutxent();
while ((utxp = getutxent()) != NULL)
@@ -269,6 +270,7 @@ main(int argc, char **argv)
#endif
} else {
#ifdef HAVE_UTMPNAME
+ struct utmp *utp;
utmpname(fn);
setutxent();
while ((utp = getutent()) != NULL)