Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/dist/ssh For ptys of the form /dev/pts/n, print foo@p...



details:   https://anonhg.NetBSD.org/src/rev/f4793d9b519d
branches:  trunk
changeset: 571070:f4793d9b519d
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 10 16:55:55 2004 +0000

description:
For ptys of the form /dev/pts/n, print foo@pts/n instead of foo@n. Check
that strrchr() returns non null before using it.

diffstat:

 crypto/dist/ssh/session.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r f0eea28a78b5 -r f4793d9b519d crypto/dist/ssh/session.c
--- a/crypto/dist/ssh/session.c Wed Nov 10 16:51:16 2004 +0000
+++ b/crypto/dist/ssh/session.c Wed Nov 10 16:55:55 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: session.c,v 1.35 2003/09/17 23:19:02 christos Exp $    */
+/*     $NetBSD: session.c,v 1.36 2004/11/10 16:55:55 christos Exp $    */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo%cs.hut.fi@localhost>, Espoo, Finland
  *                    All rights reserved
@@ -35,7 +35,7 @@
 
 #include "includes.h"
 RCSID("$OpenBSD: session.c,v 1.154 2003/03/05 22:33:43 markus Exp $");
-__RCSID("$NetBSD: session.c,v 1.35 2003/09/17 23:19:02 christos Exp $");
+__RCSID("$NetBSD: session.c,v 1.36 2004/11/10 16:55:55 christos Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -1862,9 +1862,18 @@
        for (i = 0; i < MAX_SESSIONS; i++) {
                Session *s = &sessions[i];
                if (s->used && s->ttyfd != -1) {
+                       char *p;
                        if (buf[0] != '\0')
                                strlcat(buf, ",", sizeof buf);
-                       strlcat(buf, strrchr(s->tty, '/') + 1, sizeof buf);
+                       if ((p = strstr(s->tty, "/pts/")) != NULL)
+                               p++;
+                       else {
+                               if ((p = strrchr(s->tty, '/')) != NULL)
+                                       p++;
+                               else
+                                       p = s->tty;
+                       }
+                       strlcat(buf, p, sizeof buf);
                }
        }
        if (buf[0] == '\0')



Home | Main Index | Thread Index | Old Index