diff options
-rw-r--r-- | usr.bin/tip/cmds.c | 16 | ||||
-rw-r--r-- | usr.bin/tip/hunt.c | 7 | ||||
-rw-r--r-- | usr.bin/tip/remote.c | 6 | ||||
-rw-r--r-- | usr.bin/tip/tip.h | 3 | ||||
-rw-r--r-- | usr.bin/tip/value.c | 39 |
5 files changed, 37 insertions, 34 deletions
diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c index 8d66a492909..f80e1e71f88 100644 --- a/usr.bin/tip/cmds.c +++ b/usr.bin/tip/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.3 1996/06/26 05:40:41 deraadt Exp $ */ +/* $OpenBSD: cmds.c,v 1.4 1996/10/15 23:47:20 millert Exp $ */ /* $NetBSD: cmds.c,v 1.6 1995/10/29 00:49:38 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: cmds.c,v 1.3 1996/06/26 05:40:41 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: cmds.c,v 1.4 1996/10/15 23:47:20 millert Exp $"; #endif /* not lint */ #include "tip.h" @@ -113,7 +113,7 @@ cu_take(cc) printf("\r\n%s: cannot create\r\n", argv[1]); return; } - sprintf(line, "cat %s;echo \01", argv[0]); + snprintf(line, sizeof(line), "cat %s;echo \01", argv[0]); transfer(line, fd, "\01"); } @@ -400,9 +400,9 @@ cu_put(cc) return; } if (boolean(value(ECHOCHECK))) - sprintf(line, "cat>%s\r", argv[1]); + snprintf(line, sizeof(line), "cat>%s\r", argv[1]); else - sprintf(line, "stty -echo;cat>%s;stty echo\r", argv[1]); + snprintf(line, sizeof(line), "stty -echo;cat>%s;stty echo\r", argv[1]); transmit(fd, "\04", line); } @@ -574,7 +574,7 @@ shell() } else { signal(SIGQUIT, SIG_DFL); signal(SIGINT, SIG_DFL); - if ((cp = rindex(value(SHELL), '/')) == NULL) + if ((cp = strrchr(value(SHELL), '/')) == NULL) cp = value(SHELL); else cp++; @@ -665,7 +665,7 @@ execute(s) { register char *cp; - if ((cp = rindex(value(SHELL), '/')) == NULL) + if ((cp = strrchr(value(SHELL), '/')) == NULL) cp = value(SHELL); else cp++; @@ -824,7 +824,7 @@ expand(name) /* signal(SIGINT, sigint) */ return(name); } - sprintf(cmdbuf, "echo %s", name); + snprintf(cmdbuf, sizeof(cmdbuf), "echo %s", name); if ((pid = vfork()) == 0) { Shell = value(SHELL); if (Shell == NOSTR) diff --git a/usr.bin/tip/hunt.c b/usr.bin/tip/hunt.c index 1d5952f6cdd..bcf92ac794b 100644 --- a/usr.bin/tip/hunt.c +++ b/usr.bin/tip/hunt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hunt.c,v 1.3 1996/06/26 05:40:43 deraadt Exp $ */ +/* $OpenBSD: hunt.c,v 1.4 1996/10/15 23:47:21 millert Exp $ */ /* $NetBSD: hunt.c,v 1.5 1995/10/29 00:49:40 pk Exp $ */ /* @@ -38,13 +38,12 @@ #if 0 static char sccsid[] = "@(#)hunt.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: hunt.c,v 1.3 1996/06/26 05:40:43 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: hunt.c,v 1.4 1996/10/15 23:47:21 millert Exp $"; #endif /* not lint */ #include "tip.h" extern char *getremote(); -extern char *rindex(); static jmp_buf deadline; static int deadfl; @@ -66,7 +65,7 @@ hunt(name) f = signal(SIGALRM, dead); while (cp = getremote(name)) { deadfl = 0; - uucplock = rindex(cp, '/')+1; + uucplock = strrchr(cp, '/')+1; if (uu_lock(uucplock) < 0) continue; /* diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c index 883807e36fe..4e5e8447528 100644 --- a/usr.bin/tip/remote.c +++ b/usr.bin/tip/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.2 1996/06/26 05:40:46 deraadt Exp $ */ +/* $OpenBSD: remote.c,v 1.3 1996/10/15 23:47:21 millert Exp $ */ /* $NetBSD: remote.c,v 1.3 1994/12/08 09:31:03 jtc Exp $ */ /* @@ -45,7 +45,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)remote.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: remote.c,v 1.2 1996/06/26 05:40:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: remote.c,v 1.3 1996/10/15 23:47:21 millert Exp $"; #endif /* not lint */ #include <stdio.h> @@ -220,7 +220,7 @@ getremote(host) */ if (next == NOSTR) return (NOSTR); - if ((cp = index(next, ',')) == NULL) { + if ((cp = strchr(next, ',')) == NULL) { DV = next; next = NOSTR; } else { diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h index 85ee224f98f..f2425a95812 100644 --- a/usr.bin/tip/tip.h +++ b/usr.bin/tip/tip.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tip.h,v 1.3 1996/06/26 05:40:47 deraadt Exp $ */ +/* $OpenBSD: tip.h,v 1.4 1996/10/15 23:47:22 millert Exp $ */ /* $NetBSD: tip.h,v 1.4 1995/10/29 00:49:43 pk Exp $ */ /* @@ -42,7 +42,6 @@ */ #include <sys/types.h> -#include <machine/endian.h> #include <sys/file.h> #include <sys/time.h> diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c index 20eef43a3a6..69063eb8f47 100644 --- a/usr.bin/tip/value.c +++ b/usr.bin/tip/value.c @@ -1,4 +1,4 @@ -/* $OpenBSD: value.c,v 1.2 1996/06/26 05:40:49 deraadt Exp $ */ +/* $OpenBSD: value.c,v 1.3 1996/10/15 23:47:22 millert Exp $ */ /* $NetBSD: value.c,v 1.3 1994/12/08 09:31:17 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: value.c,v 1.2 1996/06/26 05:40:49 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: value.c,v 1.3 1996/10/15 23:47:22 millert Exp $"; #endif /* not lint */ #include "tip.h" @@ -56,7 +56,7 @@ vinit() register value_t *p; register char *cp; FILE *f; - char file[256]; + char file[FILENAME_MAX]; for (p = vtable; p->v_name != NULL; p++) { if (p->v_type&ENVIRON) @@ -69,19 +69,24 @@ vinit() * Read the .tiprc file in the HOME directory * for sets */ - strcpy(file, value(HOME)); - strcat(file, "/.tiprc"); - if ((f = fopen(file, "r")) != NULL) { - register char *tp; - - while (fgets(file, sizeof(file)-1, f) != NULL) { - if (vflag) - printf("set %s", file); - if (tp = rindex(file, '\n')) - *tp = '\0'; - vlex(file); + if (strlen(value(HOME)) + sizeof("/.tiprc") > sizeof(file)) { + fprintf(stderr, "Home directory path too long: %s\n", + value(HOME)); + } else { + strcpy(file, value(HOME)); + strcat(file, "/.tiprc"); + if ((f = fopen(file, "r")) != NULL) { + register char *tp; + + while (fgets(file, sizeof(file)-1, f) != NULL) { + if (vflag) + printf("set %s", file); + if (tp = strrchr(file, '\n')) + *tp = '\0'; + vlex(file); + } + fclose(f); } - fclose(f); } /* * To allow definition of exception prior to fork @@ -172,7 +177,7 @@ vtoken(s) register char *cp; char *expand(); - if (cp = index(s, '=')) { + if (cp = strchr(s, '=')) { *cp = '\0'; if (p = vlookup(s)) { cp++; @@ -185,7 +190,7 @@ vtoken(s) } return; } - } else if (cp = index(s, '?')) { + } else if (cp = strchr(s, '?')) { *cp = '\0'; if ((p = vlookup(s)) && vaccess(p->v_access, READ)) { vprint(p); |