Fix a seg-fault if -l is used without a /dev prefix, e.g. cu -l cuaa0. Of
authorMatthew Dillon <dillon@dragonflybsd.org>
Tue, 26 Oct 2004 22:10:13 +0000 (22:10 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Tue, 26 Oct 2004 22:10:13 +0000 (22:10 +0000)
course, this still fails because -l expects a device path, but at least now
it doesn't seg-fault.

Reported-by: Mark Cullen <mark.cullen@dsl.pipex.com>
usr.bin/tip/tip/hunt.c

index 7f50d8e..b12deb8 100644 (file)
@@ -32,7 +32,7 @@
  *
  * @(#)hunt.c  8.1 (Berkeley) 6/6/93
  * $FreeBSD: src/usr.bin/tip/tip/hunt.c,v 1.5 1999/08/28 01:06:33 peter Exp $
- * $DragonFly: src/usr.bin/tip/tip/hunt.c,v 1.2 2003/06/17 04:29:32 dillon Exp $
+ * $DragonFly: src/usr.bin/tip/tip/hunt.c,v 1.3 2004/10/26 22:10:13 dillon Exp $
  */
 
 #include <sys/types.h>
@@ -65,7 +65,10 @@ hunt(name)
        f = signal(SIGALRM, dead);
        while ((cp = getremote(name))) {
                deadfl = 0;
-               uucplock = rindex(cp, '/')+1;
+               if ((uucplock = strrchr(cp, '/')) == NULL)
+                       uucplock = cp;
+               else
+                       ++uucplock;
                if ((res = uu_lock(uucplock)) != UU_LOCK_OK) {
                        if (res != UU_LOCK_INUSE)
                                fprintf(stderr, "uu_lock: %s\n", uu_lockerr(res));