diff options
-rw-r--r-- | usr.bin/mg/file.c | 4 | ||||
-rw-r--r-- | usr.bin/mg/main.c | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 5a168644f0a..69dfd6d7159 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.32 2005/04/03 02:09:28 db Exp $ */ +/* $OpenBSD: file.c,v 1.33 2005/04/21 19:16:21 beck Exp $ */ /* * File commands. @@ -128,6 +128,8 @@ findbuffer(char *fname) return (bp); } i = strlcpy(bname, basename(fname), sizeof(bname)); + if (i >= sizeof(bname)) + return NULL; remain = sizeof(bname) - i; for (count = 2; bfind(bname, FALSE) != NULL; count++) snprintf(&bname[i], remain, "<%d>", count); diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index e7ca3f6897c..e2e4014519e 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.38 2005/04/03 02:09:28 db Exp $ */ +/* $OpenBSD: main.c,v 1.39 2005/04/21 19:16:21 beck Exp $ */ /* * Mainline. @@ -110,7 +110,10 @@ notnum: if (nfiles == 1) splitwind(0, 1); - curbp = findbuffer(cp); + if ((curbp = findbuffer(cp)) == NULL) { + vttidy(); + errx(1, "Can't find current buffer!"); + } (void)showbuffer(curbp, curwp, 0); if ((status = readin(cp)) != TRUE) killbuffer(curbp); |