diff options
author | 2005-04-21 19:16:21 +0000 | |
---|---|---|
committer | 2005-04-21 19:16:21 +0000 | |
commit | 26c2e9069a9461fc9472f482f8ef24e4127b42f6 (patch) | |
tree | 95d66febf4d4b97f002b372128150a71ef33b2e9 | |
parent | better include the cvs_sendfile() req in the conditional statement so (diff) | |
download | wireguard-openbsd-26c2e9069a9461fc9472f482f8ef24e4127b42f6.tar.xz wireguard-openbsd-26c2e9069a9461fc9472f482f8ef24e4127b42f6.zip |
correct strlcpy abuse, and always check for NULL return from find_buffer
ok cloder@, feedback from many
-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); |